Solved

is inaccessible due to its protection level

Posted on 2004-09-25
2
11,098 Views
Last Modified: 2011-08-18
Newbie to ASP.NET / C#

I just moved my code from inline to code behind and I am getting this error:

'newsDisplay.Prev_Click(object, System.EventArgs)' is inaccessible due to its protection level

Can someone tell me what it is I have declared wrong?  I imaginge its to do with public LinkButton btnPrev; but I thought public was about as unproteced as could be.

Thanks




Heres my aspx file:

<% @Page Language="C#" Debug="true" Src="NewsReader.cs" Inherits="newsDisplay" %>


<html>
      <head>
            <title>Paging with ASP.NET - DataSet Example - c#</title>
            <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
      </head>
      <body>
            <form runat="server">
                  <font size="-1" face="Verdana, Arial, Helvetica, sans-serif"><asp:label id="pageNumber" runat="server" /></font>
                  <asp:DataList id="theDataList" runat="server">
                        <ItemTemplate>
                              <h1><%# DataBinder.Eval(Container.DataItem, "NewsSubject") %></h1>
                              <%# DataBinder.Eval(Container.DataItem, "NewsContent") %>
                        </ItemTemplate>
                        <separatortemplate>
                              <hr color="#0099FF" />
                        </separatortemplate>
                  </asp:DataList>
      
                  <asp:LinkButton id="btnPrev" Text="&lt;" OnClick="Prev_Click" runat="server" />
                  <asp:LinkButton id="btnNext" Text="&gt;" OnClick="Next_Click" runat="server" />
            </form>
</html>


And the CS file:

using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.OleDb;

public class newsDisplay : Page
{
      PagedDataSource pagedData = new PagedDataSource();

       public LinkButton btnPrev;
       public LinkButton btnNext;
       public DataList theDataList;
 
      void Page_Load(Object obj, EventArgs e)
      {
            doPaging();
      }
      
      public DataTable getTheData()
      {
                  DataSet DS = new DataSet();
                  OleDbConnection strConnect = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\\InetPub\\Database\\sixfive.mdb");
                  OleDbDataAdapter objSQLAdapter = new OleDbDataAdapter("SELECT * FROM News", strConnect);
                  objSQLAdapter.Fill(DS, "customers");
                  
                  return DS.Tables[0];
      }
      
      void doPaging()
      {
            pagedData.DataSource = getTheData().DefaultView;
            pagedData.AllowPaging = true;
            pagedData.PageSize = 5;
            
            try {
                  pagedData.CurrentPageIndex = Int32.Parse(Request["Page"].ToString());
            } catch (Exception ex) {
                  pagedData.CurrentPageIndex = 0;
            }
      
            btnPrev.Visible = (!pagedData.IsFirstPage);
            btnNext.Visible = (!pagedData.IsLastPage);
            
            theDataList.DataSource = pagedData;
            theDataList.DataBind();
      }
      
      void Prev_Click(Object obj, EventArgs e)
      {
            Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex - 1));
      }
      
      void Next_Click(Object obj, EventArgs e)
      {
            Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex + 1));
      }
}
0
Comment
Question by:mmc98dl1
2 Comments
 
LVL 8

Expert Comment

by:razo
ID: 12149641
try declaring the function prev_click as public
0
 
LVL 28

Accepted Solution

by:
mmarinov earned 50 total points
ID: 12149724
Hi,

you have to replace these
     void Prev_Click(Object obj, EventArgs e)
     {
          Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex - 1));
     }
     
     void Next_Click(Object obj, EventArgs e)
     {
          Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex + 1));
     }
with
     public void Prev_Click(Object obj, EventArgs e)
     {
          Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex - 1));
     }
     
     public void Next_Click(Object obj, EventArgs e)
     {
          Response.Redirect(Request.CurrentExecutionFilePath + "?Page=" + (pagedData.CurrentPageIndex + 1));
     }

Regards,
B..M
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

709 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now