?
Solved

is inaccessible due to its protection level

Posted on 2004-09-25
2
Medium Priority
?
11,226 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 200 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

770 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