I have register a page using the code
我已经使用代码注册了一个页面
<%@ Register TagPrefix="uc1" TagName="side" Src="side.ascx" %>
And called this by using the code
并通过使用代码调用此方法
<uc1:side ID="Side1" runat="server"></uc1:side>
And i tried to acces the ID="Side1" in behind by using
我试图通过使用来访问后面的ID =“Side1”
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if (Session["UName"] != null || Session["UName"] != " ")
{
Side1.Visible = true;
}
else
Side1.Visible = true;
}
but gives the error
但是给出了错误
The name 'Side1' does not exist in the current context .
当前上下文中不存在名称“Side1”。
How will i resolve it by accessing the 'id' using 'protected System.Web.UI'.
如何通过使用'protected System.Web.UI'访问'id'来解决它。
1 个解决方案
#1
0
Check the access modifier on your WebUserControl partial class definition (ie YourControl.ascx.cs file), it should be something like this:
检查WebUserControl部分类定义(即YourControl.ascx.cs文件)上的访问修饰符,它应该是这样的:
public partial class SideControl : System.Web.UI.UserControl
{
// your code...
}
You can find more information about access modifiers here.
您可以在此处找到有关访问修饰符的更多信息。
#1
0
Check the access modifier on your WebUserControl partial class definition (ie YourControl.ascx.cs file), it should be something like this:
检查WebUserControl部分类定义(即YourControl.ascx.cs文件)上的访问修饰符,它应该是这样的:
public partial class SideControl : System.Web.UI.UserControl
{
// your code...
}
You can find more information about access modifiers here.
您可以在此处找到有关访问修饰符的更多信息。