从子页访问asp.net母版页上的控件
我想从子页面访问asp.net母版页上的跨距,因此我在该母版页上设置了一个公共属性--> 现在想从子页面访问它,将一些文本设置到htmlanchor标记中 所以我写了一些脚本--> 子页面从子页访问asp.net母版页上的控件,asp.net,Asp.net,我想从子页面访问asp.net母版页上的跨距,因此我在该母版页上设置了一个公共属性--> 现在想从子页面访问它,将一些文本设置到htmlanchor标记中 所以我写了一些脚本--> 子页面 public partial class Ui_ProductDetails : System.Web.UI.Page { protected void ListView_ProductDetails_itemcommand(object sender, ListViewCommandEventArgs e)
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您需要将Page.Master属性强制转换为母版页的类型
((Ui_MasterPage_UI)Page.Master).Notification = "some text";
Frazell在这里的解释、示例和细节都是正确的。
((Ui_MasterPage_UI)Page.Master).Notification = "some text";