Link to home
Start Free TrialLog in
Avatar of Kaporch
Kaporch

asked on

Button on page inaccessible due to protection level

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?
Avatar of Mihai Stancescu
Mihai Stancescu
Flag of Romania image

Make sure your base class that contains the btnSelect in public, or internal, and btnSelect is also public, internal...


Hope helps...

Regards,
Mishu.
Avatar of Kaporch
Kaporch

ASKER

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?
Yeah, probably thats why you can't use it. Try put it internal or public....
This should solve the problem.


Regards,
Mishu
Avatar of Kaporch

ASKER

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;

ASKER CERTIFIED SOLUTION
Avatar of Mihai Stancescu
Mihai Stancescu
Flag of Romania image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Kaporch

ASKER

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)