Solved

Button on page inaccessible due to protection level

Posted on 2006-10-31
6
607 Views
Last Modified: 2012-06-27
The code behind page is as follows:


<%@ Page language="c#" Codebehind="Collaboration.aspx.cs" AutoEventWireup="false" Inherits="emnet.meetings.request.collaboration" %>
<%@ Register TagPrefix="webnotes" TagName="webnotes" Src="stepnotes.ascx" %>
<%@ Register TagPrefix="summary" TagName="summary" Src="requestsummary.ascx" %>
<%@ Register TagPrefix="stepnav" TagName="steps" Src="requeststeps.ascx" %>
<%@ Register TagPrefix="uc1" TagName="header" Src="../../common/header_meeting.ascx" %>
<%@ Register TagPrefix="uc2" TagName="footer" Src="../../common/footer.ascx" %>
<!DOCTYPE html public "-//w3c//dtd html 4.0 transitional//en" >
<HTML>
      <HEAD>
            <TITLE>Meeting Request</TITLE>
            <META content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
            <META content="C#" name="CODE_LANGUAGE">
            <META content="JavaScript" name="vs_defaultClientScript">
            <META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
            <SCRIPT src="../../common/JScript.js" type="text/javascript"></SCRIPT>
            <script language="javascript" src="../../Help/RoboHelp_CSH.js" type="text/javascript"></script>
            <LINK href="../../common/meeting.css" type="text/css" rel="stylesheet">
            <SCRIPT type="text/javascript">
                  history.forward(1)
            </SCRIPT>
      </HEAD>
      <body leftMargin="0" topMargin="0" onload="LoadPage();MM_preloadImages('/images/header/meetings_over.jpg','/images/header/speakers_over.jpg','/images/header/attendees_over.jpg','/images/header/venues_over.jpg','/images/header/resources_over.jpg','/images/header/help_over.jpg','/images/header/feedback_over.jpg','/images/header/logout_over.jpg')">
            <FORM id="frmAV" method="post" runat="server">
                  <UC1:HEADER id="Header2" runat="server"></UC1:HEADER>
                  <TABLE class="blank_bg" height="80%" cellSpacing="0" cellPadding="0" width="95%" align="center">
                        <TR>
                              <TD vAlign="top">
                                    <TABLE height="100%" cellSpacing="0" cellPadding="0" width="100%">
                                          <TR>
                                                <TD vAlign="top" width="150"><STEPNAV:STEPS id="steps" runat="server"></STEPNAV:STEPS></TD>
                                                <TD vAlign="top">
                                                      <TABLE cellSpacing="5" cellPadding="5" width="100%">
                                                            <TBODY>
                                                                  <TR>
                                                                        <TD><ASP:LABEL id="lblMessage" runat="server" cssclass="errormessage" enableviewstate="False"></ASP:LABEL></TD>
                                                                  </TR>
                                                                  <TR>
                                                                        <TD><SUMMARY:SUMMARY id="summary" runat="server"></SUMMARY:SUMMARY></TD>
                                                                  </TR>
                                                                  <TR>
                                                                        <TD><WEBNOTES:WEBNOTES id="webnotes" runat="server"></WEBNOTES:WEBNOTES></TD>
                                                                  </TR>
                                                                  <TR>
                                                                        <TD vAlign="top">
                                                                              <TABLE width="100%" align="center">
                                                                                    <TR>
                                                                                          <TD vAlign="top" align="left">
                                                                                                <TABLE class="filtertable" borderColor="#cccccc" cellSpacing="0" width="325" border="1">
                                                                                                      <TR>
                                                                                                            <TD class="orangeheader" align="center" colSpan="2">Employee Search Filter</TD>
                                                                                                      </TR>
                                                                                                      <TR>
                                                                                                            <TH>
                                                                                                                  Rep Last Name</TH>
                                                                                                            <TD><ASP:TEXTBOX id="txtName" runat="server" maxlength="25"></ASP:TEXTBOX></TD>
                                                                                                      </TR>
                                                                                                      <TR>
                                                                                                            <TH>
                                                                                                                  Territory</TH>
                                                                                                            <TD><ASP:TEXTBOX id="txtTerritory" runat="server" maxlength="10"></ASP:TEXTBOX></TD>
                                                                                                      </TR>
                                                                                                      <TR>
                                                                                                            <TH>
                                                                                                                  State</TH>
                                                                                                            <TD><ASP:DROPDOWNLIST id="ddlState" runat="server" enableviewstate="False" width="155"></ASP:DROPDOWNLIST></TD>
                                                                                                      </TR>
                                                                                                      <TR>
                                                                                                            <TD colSpan="2"><asp:button id="btnSearch" onclick="btnSearch_Click" Text="Search" Runat="server"></asp:button></TD>
                                                                                                      </TR>
                                                                                                </TABLE>
                                                                                          </TD>
                                                                                          <TD vAlign="top" align="right">
                                                                                                <TABLE cellSpacing="0" cellPadding="0" width="90%" border="0">
                                                                                                      <TR id="trBasket" runat="server">
                                                                                                            <TD class="orangeheader" colSpan="2">Selected Employees</TD>
                                                                                                      </TR>
                                                                                                      <tr>
                                                                                                            <td colSpan="1" align="right"><ASP:DATAGRID id="dgBasket" runat="server" cssClass="datagrid" enableviewstate="true" allowcustompaging="false"
                                                                                                                        onpageindexchanged="dgBasket_Page" pagesize="8" OnPreRender="dgBasket_PreRender" autogeneratecolumns="false" allowpaging="true"
                                                                                                                        AllowSorting="false" onDeleteCommand="dgBasket_Delete" OnItemDataBound="dgBasket_ItemDataBound" DataKeyField="ID" cellpadding="3">
                                                                                                                        <PagerStyle mode="NumericPages" Position="Bottom" cssclass="dgPager" ForeColor="#FFFFFF"></PagerStyle>
                                                                                                                        <HeaderStyle cssClass="dgHeader" ForeColor="#FFFFFF"></HeaderStyle>
                                                                                                                        <Columns>
                                                                                                                              <ASP:TemplateColumn>
                                                                                                                                    <ItemTemplate>
                                                                                                                                          <%# this.dgBasket.CurrentPageIndex * this.dgBasket.PageSize + Container.ItemIndex + 1%>
                                                                                                                                    </ItemTemplate>
                                                                                                                              </ASP:TemplateColumn>
                                                                                                                              <asp:BoundColumn DataField="Name" HeaderText="Name"></asp:BoundColumn>
                                                                                                                              <asp:BoundColumn DataField="Location" HeaderText="City, State"></asp:BoundColumn>
                                                                                                                              <ASP:ButtonColumn Text="Delete" CommandName="Delete"></ASP:ButtonColumn>
                                                                                                                        </Columns>
                                                                                                                  </ASP:DATAGRID></td>
                                                                                                      </tr>
                                                                                                      <TR>
                                                                                                            <TD colSpan="2">&nbsp;</TD>
                                                                                                      </TR>
                                                                                                      <TR>
                                                                                                            <td align="left">&nbsp;</td>
                                                                                                            <td align="right"><asp:button id="btnNext" Visible="false" OnClick="btnNext_Click" Runat="server" Text="Next Step >"
                                                                                                                        EnableViewState="False"></asp:button></td>
                                                                                                      </TR>
                                                                                                </TABLE>
                                                                                          </TD>
                                                                                    </TR>
                                                                              </TABLE>
                                                                        </TD>
                                                                  </TR>
                                                                  <TR>
                                                                        <TD colSpan="2"><ASP:TABLE id="tblResults" runat="server" width="100%" cellspacing="0" visible="False">
                                                                                    <ASP:TABLEROW>
                                                                                          <ASP:TABLECELL cssclass="orangeheader" columnspan="2">
                                                                                                <ASP:LABEL id="lblConfirmVenue" runat="server"></ASP:LABEL>
                                                                                          </ASP:TABLECELL>
                                                                                    </ASP:TABLEROW>
                                                                                    <ASP:TABLEROW>
                                                                                          <ASP:TABLECELL cssclass="orangeheaderleft">
                                                                                                <asp:Label id="lblTotalRecords" runat="server"></asp:Label>
                                                                                          </ASP:TABLECELL>
                                                                                          <ASP:TABLECELL cssclass="orangeheaderright" horizontalalign="Right">
                                                                                                <ASP:LABEL id="lblSearchTotal" runat="server" enableviewstate="False"></ASP:LABEL>
                                                                                          </ASP:TABLECELL>
                                                                                    </ASP:TABLEROW>
                                                                                    <ASP:TABLEROW>
                                                                                          <ASP:TABLECELL columnspan="2">
                                                                                                <ASP:DATAGRID id="dgTerritory" gridlines="Both" runat="server" CellPadding="3" allowpaging="true"
                                                                                                      onitemdatabound="dgTerritory_ItemDataBound" allowcustompaging="false" autogeneratecolumns="false"
                                                                                                      onpageindexchanged="Change_dgTerritory" pagesize="25" width="100%" OnPreRender="PreRender_dgTerritory"
                                                                                                      AllowSorting="True" OnSortCommand="Sort_dgTerritory">
                                                                                                      <HEADERSTYLE CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></HEADERSTYLE>
                                                                                                      <PAGERSTYLE mode="NumericPages" HORIZONTALALIGN="Center" CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></PAGERSTYLE>
                                                                                                      <COLUMNS>
                                                                                                            <ASP:BOUNDCOLUMN headertext="Select" datafield="Select"></ASP:BOUNDCOLUMN>
                                                                                                            <ASP:BOUNDCOLUMN headertext="Territory #" datafield="territory" SortExpression="territory"></ASP:BOUNDCOLUMN>
                                                                                                            <ASP:BOUNDCOLUMN headertext="Rep" datafield="rep_name" SortExpression="rep_name"></ASP:BOUNDCOLUMN>
                                                                                                            <ASP:BOUNDCOLUMN headertext="Location" datafield="location" SortExpression="location"></ASP:BOUNDCOLUMN>
                                                                                                            <ASP:BOUNDCOLUMN headertext="Notes" datafield="Notes"></ASP:BOUNDCOLUMN>
                                                                                                      </COLUMNS>
                                                                                                </ASP:DATAGRID>
                                                                                          </ASP:TABLECELL>
                                                                                    </ASP:TABLEROW>
                                                                              </ASP:TABLE></TD>
                                                                  </TR>
                                                                  <tr>
                                                                        <TD align="left" colSpan="2"><asp:button id="btnSelect" onclick="btnSelect_Click" Runat="server" Text="Add to Selection Basket"
                                                                                    EnableViewState="False" Enabled="False"></asp:button></TD>
                                                                  </tr>
                                                                  <tr>
                                                                        <td><input id="hidCheckBox" type="hidden" name="hidCheckBox" runat="server"></td>
                                                                  </tr>
                                                </TD>
                                          </TR>
                                    </TABLE>
                              </TD>
                        </TR>
                  </TABLE>
                  <UC2:FOOTER id="Footer1" runat="server"></UC2:FOOTER></FORM>
            </TD></TR></TBODY></TABLE>
      </body>
</HTML>



I'm getting a message that btnSelect is inaccessible due to protection level when I run this page.  What do I need to change to get rid of this error?
0
Comment
Question by:Kaporch
  • 3
  • 3
6 Comments
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 17842988
Make sure your base class that contains the btnSelect in public, or internal, and btnSelect is also public, internal...


Hope helps...

Regards,
Mishu.
0
 

Author Comment

by:Kaporch
ID: 17844151
This is the way the button is declared, which is done by C#:

public class collaboration : System.Web.UI.Page
      {

            protected System.Web.UI.WebControls.Label lblMessage;
            protected System.Collections.Hashtable objError = new Hashtable();      

            protected System.Web.UI.WebControls.DropDownList ddlState;
            protected System.Web.UI.WebControls.Table tblResults;
            protected System.Web.UI.WebControls.DataGrid dgTerritory;
            protected System.Web.UI.WebControls.Label lblSearchTotal;
            protected System.Web.UI.WebControls.Button btnSubmit;
            protected System.Web.UI.WebControls.TextBox txtName;
            protected System.Web.UI.WebControls.TextBox txtTerritory;
            protected System.Web.UI.WebControls.Button btnSearch;
            protected System.Web.UI.WebControls.Label lblTotalRecords;
            protected System.Web.UI.WebControls.Button btnSelect;
            protected System.Web.UI.HtmlControls.HtmlInputHidden hidCheckBox;
            protected System.Web.UI.WebControls.DataGrid dgBasket;
            protected System.Web.UI.HtmlControls.HtmlTableRow trBasket;
            protected System.Web.UI.WebControls.Label lblConfirmVenue;
            protected System.Web.UI.WebControls.Button btnNext;

Are you saying that the button shouldn't be protected?
0
 
LVL 11

Expert Comment

by:Mihai Stancescu
ID: 17844374
Yeah, probably thats why you can't use it. Try put it internal or public....
This should solve the problem.


Regards,
Mishu
0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

Author Comment

by:Kaporch
ID: 17849569
That did not work.  I'm still getting the error with this code:

public class collaboration : System.Web.UI.Page
      {

            protected System.Web.UI.WebControls.Label lblMessage;
            protected System.Collections.Hashtable objError = new Hashtable();      

            protected System.Web.UI.WebControls.DropDownList ddlState;
            protected System.Web.UI.WebControls.Table tblResults;
            protected System.Web.UI.WebControls.DataGrid dgTerritory;
            protected System.Web.UI.WebControls.Label lblSearchTotal;
            protected System.Web.UI.WebControls.Button btnSubmit;
            protected System.Web.UI.WebControls.TextBox txtName;
            protected System.Web.UI.WebControls.TextBox txtTerritory;
            protected System.Web.UI.WebControls.Button btnSearch;
            protected System.Web.UI.WebControls.Label lblTotalRecords;
            public System.Web.UI.WebControls.Button btnSelect;
            protected System.Web.UI.HtmlControls.HtmlInputHidden hidCheckBox;
            protected System.Web.UI.WebControls.DataGrid dgBasket;
            protected System.Web.UI.HtmlControls.HtmlTableRow trBasket;
            protected System.Web.UI.WebControls.Label lblConfirmVenue;
            protected System.Web.UI.WebControls.Button btnNext;

0
 
LVL 11

Accepted Solution

by:
Mihai Stancescu earned 500 total points
ID: 17849767
I saw in your page code that you set the button property "enabled = false".

And thats why probably in the initialize component method, it can't be accessed.

Try set the enabled property to false in you C# code, on PageLoad or other init method that you have.

You get the error when you compile the page ( at a certain line), or when you run the page?


Regards,
Mishu
0
 

Author Comment

by:Kaporch
ID: 17849987
That wasn't the problem.  I found it.  I had for some reason this in my code:

private void btnSelect_Click(object sender, System.EventArgs e)

which I changed to

public void btnSelect_Click(object sender, System.EventArgs e)
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

778 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