Asp.net 子页中的访问母版页控件
我想从子页面访问asp.net母版页上的跨距,因此我在该母版页上创建了一个公共属性-->Asp.net 子页中的访问母版页控件,asp.net,Asp.net,我想从子页面访问asp.net母版页上的跨距,因此我在该母版页上创建了一个公共属性--> 母版页 public partial class Ui_MasterPage_UI : System.Web.UI.MasterPage { public int tax = 0; public string notification { set { (this.Find
母版页
public partial class Ui_MasterPage_UI : System.Web.UI.MasterPage
{
public int tax = 0;
public string notification
{
set
{
(this.FindControl("notification") as HtmlAnchor).InnerText = value.ToString();
}
}
------------------//some code
}
public partial class Ui_ProductDetails : System.Web.UI.Page
{
protected void ListView_ProductDetails_itemcommand(object sender, ListViewCommandEventArgs e)
{
Master.notification = "some text"; ////////showing error
------------------//some code
}
------------------//some code
}
现在我想从子页面访问它,将一些文本设置到htmlanchor标记中,这样我就可以编写一些脚本-->
子页面
public partial class Ui_MasterPage_UI : System.Web.UI.MasterPage
{
public int tax = 0;
public string notification
{
set
{
(this.FindControl("notification") as HtmlAnchor).InnerText = value.ToString();
}
}
------------------//some code
}
public partial class Ui_ProductDetails : System.Web.UI.Page
{
protected void ListView_ProductDetails_itemcommand(object sender, ListViewCommandEventArgs e)
{
Master.notification = "some text"; ////////showing error
------------------//some code
}
------------------//some code
}
但是得到语法错误
我认为上面的代码有一些问题,,,,,所以请大家检查一下。。。。。。
还有其他方法吗???
thnku将属性runat=“server”和clientMode=“static”添加到id为“notification”的HtmlAnchor中可以使代码:
(Master.FindControl("notification") as HtmlAnchor).InnerText = "whatever"
在每个子页面中工作
编辑:我想说,您不需要该公共方法…请添加您收到的错误消息。