Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

is inaccessible due to its protection level

Posted on 2004-09-25
2
Medium Priority
?
11,264 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

618 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