Solved

is inaccessible due to its protection level

Posted on 2004-09-25
2
11,175 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 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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
asp Google Map 2 91
Query in AngularJS 8 80
Run software updates from the website 6 49
Adding Rows to Grid 4 29
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 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