Solved

Button on page inaccessible due to protection level

Posted on 2006-10-31
6
590 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
Comment Utility
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
Comment Utility
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
Comment Utility
Yeah, probably thats why you can't use it. Try put it internal or public....
This should solve the problem.


Regards,
Mishu
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Author Comment

by:Kaporch
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

771 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now