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.r equest.col laboration " %>
<%@ 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_m eeting.asc x" %>
<%@ Register TagPrefix="uc2" TagName="footer" Src="../../common/footer.a scx" %>
<!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_defaultClientScri pt">
<META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<SCRIPT src="../../common/JScript. js" type="text/javascript"></S CRIPT>
<script language="javascript" src="../../Help/RoboHelp_C SH.js" type="text/javascript"></s cript>
<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_prel oadImages( '/images/h eader/meet ings_over. jpg','/ima ges/header /speakers_ over.jpg', '/images/h eader/atte ndees_over .jpg','/im ages/heade r/venues_o ver.jpg',' /images/he ader/resou rces_over. jpg','/ima ges/header /help_over .jpg','/im ages/heade r/feedback _over.jpg' ,'/images/ header/log out_over.j pg')">
<FORM id="frmAV" method="post" runat="server">
<UC1:HEADER id="Header2" runat="server"></UC1:HEADE R>
<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:S TEPS></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:S UMMARY></T D>
</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:TEXTB OX></TD>
</TR>
<TR>
<TH>
Territory</TH>
<TD><ASP:TEXTBOX id="txtTerritory" runat="server" maxlength="10"></ASP:TEXTB OX></TD>
</TR>
<TR>
<TH>
State</TH>
<TD><ASP:DROPDOWNLIST id="ddlState" runat="server" enableviewstate="False" width="155"></ASP:DROPDOWN LIST></TD>
</TR>
<TR>
<TD colSpan="2"><asp:button id="btnSearch" onclick="btnSearch_Click" Text="Search" Runat="server"></asp:butto n></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:DATAGRI D id="dgBasket" runat="server" cssClass="datagrid" enableviewstate="true" allowcustompaging="false"
onpageindexchanged="dgBask et_Page" pagesize="8" OnPreRender="dgBasket_PreR ender" autogeneratecolumns="false " allowpaging="true"
AllowSorting="false" onDeleteCommand="dgBasket_ Delete" OnItemDataBound="dgBasket_ ItemDataBo und" DataKeyField="ID" cellpadding="3">
<PagerStyle mode="NumericPages" Position="Bottom" cssclass="dgPager" ForeColor="#FFFFFF"></Page rStyle>
<HeaderStyle cssClass="dgHeader" ForeColor="#FFFFFF"></Head erStyle>
<Columns>
<ASP:TemplateColumn>
<ItemTemplate>
<%# this.dgBasket.CurrentPageI ndex * this.dgBasket.PageSize + Container.ItemIndex + 1%>
</ItemTemplate>
</ASP:TemplateColumn>
<asp:BoundColumn DataField="Name" HeaderText="Name"></asp:Bo undColumn>
<asp:BoundColumn DataField="Location" HeaderText="City, State"></asp:BoundColumn>
<ASP:ButtonColumn Text="Delete" CommandName="Delete"></ASP :ButtonCol umn>
</Columns>
</ASP:DATAGRID></td>
</tr>
<TR>
<TD colSpan="2"> </TD>
</TR>
<TR>
<td align="left"> </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="orangeheaderrigh t" 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="dgTerrito ry_ItemDat aBound" allowcustompaging="false" autogeneratecolumns="false "
onpageindexchanged="Change _dgTerrito ry" pagesize="25" width="100%" OnPreRender="PreRender_dgT erritory"
AllowSorting="True" OnSortCommand="Sort_dgTerr itory">
<HEADERSTYLE CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></HEAD ERSTYLE>
<PAGERSTYLE mode="NumericPages" HORIZONTALALIGN="Center" CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></PAGE RSTYLE>
<COLUMNS>
<ASP:BOUNDCOLUMN headertext="Select" datafield="Select"></ASP:B OUNDCOLUMN >
<ASP:BOUNDCOLUMN headertext="Territory #" datafield="territory" SortExpression="territory" ></ASP:BOU NDCOLUMN>
<ASP:BOUNDCOLUMN headertext="Rep" datafield="rep_name" SortExpression="rep_name"> </ASP:BOUN DCOLUMN>
<ASP:BOUNDCOLUMN headertext="Location" datafield="location" SortExpression="location"> </ASP:BOUN DCOLUMN>
<ASP:BOUNDCOLUMN headertext="Notes" datafield="Notes"></ASP:BO UNDCOLUMN>
</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:butt on></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:FOOTE R></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?
<%@ Page language="c#" Codebehind="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_m
<%@ Register TagPrefix="uc2" TagName="footer" Src="../../common/footer.a
<!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_defaultClientScri
<META content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
<SCRIPT src="../../common/JScript.
<script language="javascript" src="../../Help/RoboHelp_C
<LINK href="../../common/meeting
<SCRIPT type="text/javascript">
history.forward(1)
</SCRIPT>
</HEAD>
<body leftMargin="0" topMargin="0" onload="LoadPage();MM_prel
<FORM id="frmAV" method="post" runat="server">
<UC1:HEADER id="Header2" runat="server"></UC1:HEADE
<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
<TD vAlign="top">
<TABLE cellSpacing="5" cellPadding="5" width="100%">
<TBODY>
<TR>
<TD><ASP:LABEL id="lblMessage" runat="server" cssclass="errormessage" enableviewstate="False"></
</TR>
<TR>
<TD><SUMMARY:SUMMARY id="summary" runat="server"></SUMMARY:S
</TR>
<TR>
<TD><WEBNOTES:WEBNOTES id="webnotes" runat="server"></WEBNOTES:
</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:TEXTB
</TR>
<TR>
<TH>
Territory</TH>
<TD><ASP:TEXTBOX id="txtTerritory" runat="server" maxlength="10"></ASP:TEXTB
</TR>
<TR>
<TH>
State</TH>
<TD><ASP:DROPDOWNLIST id="ddlState" runat="server" enableviewstate="False" width="155"></ASP:DROPDOWN
</TR>
<TR>
<TD colSpan="2"><asp:button id="btnSearch" onclick="btnSearch_Click" Text="Search" Runat="server"></asp:butto
</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:DATAGRI
onpageindexchanged="dgBask
AllowSorting="false" onDeleteCommand="dgBasket_
<PagerStyle mode="NumericPages" Position="Bottom" cssclass="dgPager" ForeColor="#FFFFFF"></Page
<HeaderStyle cssClass="dgHeader" ForeColor="#FFFFFF"></Head
<Columns>
<ASP:TemplateColumn>
<ItemTemplate>
<%# this.dgBasket.CurrentPageI
</ItemTemplate>
</ASP:TemplateColumn>
<asp:BoundColumn DataField="Name" HeaderText="Name"></asp:Bo
<asp:BoundColumn DataField="Location" HeaderText="City, State"></asp:BoundColumn>
<ASP:ButtonColumn Text="Delete" CommandName="Delete"></ASP
</Columns>
</ASP:DATAGRID></td>
</tr>
<TR>
<TD colSpan="2"> </TD>
</TR>
<TR>
<td align="left"> </td>
<td align="right"><asp:button id="btnNext" Visible="false" OnClick="btnNext_Click" Runat="server" Text="Next Step >"
EnableViewState="False"></
</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="orangeheaderrigh
<ASP:LABEL id="lblSearchTotal" runat="server" enableviewstate="False"></
</ASP:TABLECELL>
</ASP:TABLEROW>
<ASP:TABLEROW>
<ASP:TABLECELL columnspan="2">
<ASP:DATAGRID id="dgTerritory" gridlines="Both" runat="server" CellPadding="3" allowpaging="true"
onitemdatabound="dgTerrito
onpageindexchanged="Change
AllowSorting="True" OnSortCommand="Sort_dgTerr
<HEADERSTYLE CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></HEAD
<PAGERSTYLE mode="NumericPages" HORIZONTALALIGN="Center" CSSCLASS="dgHeader" FORECOLOR="#FFFFFF"></PAGE
<COLUMNS>
<ASP:BOUNDCOLUMN headertext="Select" datafield="Select"></ASP:B
<ASP:BOUNDCOLUMN headertext="Territory #" datafield="territory" SortExpression="territory"
<ASP:BOUNDCOLUMN headertext="Rep" datafield="rep_name" SortExpression="rep_name">
<ASP:BOUNDCOLUMN headertext="Location" datafield="location" SortExpression="location">
<ASP:BOUNDCOLUMN headertext="Notes" datafield="Notes"></ASP:BO
</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:butt
</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:FOOTE
</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?
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.Hashtab le objError = new Hashtable();
protected System.Web.UI.WebControls. DropDownLi st 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 .HtmlInput Hidden hidCheckBox;
protected System.Web.UI.WebControls. DataGrid dgBasket;
protected System.Web.UI.HtmlControls .HtmlTable Row 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?
public class collaboration : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Collections.Hashtab
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
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
This should solve the problem.
Regards,
Mishu
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.Hashtab le objError = new Hashtable();
protected System.Web.UI.WebControls. DropDownLi st 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 .HtmlInput Hidden hidCheckBox;
protected System.Web.UI.WebControls. DataGrid dgBasket;
protected System.Web.UI.HtmlControls .HtmlTable Row trBasket;
protected System.Web.UI.WebControls. Label lblConfirmVenue;
protected System.Web.UI.WebControls. Button btnNext;
public class collaboration : System.Web.UI.Page
{
protected System.Web.UI.WebControls.
protected System.Collections.Hashtab
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
public System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.HtmlControls
protected System.Web.UI.WebControls.
protected System.Web.UI.WebControls.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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)
private void btnSelect_Click(object sender, System.EventArgs e)
which I changed to
public void btnSelect_Click(object sender, System.EventArgs e)
Hope helps...
Regards,
Mishu.