【发布时间】:2012-10-12 06:41:52
【问题描述】:
在项目母版页中没有代码隐藏文件;在内容页面中,我需要阅读母版页内的用户控件属性。能否请您建议如何完成。
【问题讨论】:
在项目母版页中没有代码隐藏文件;在内容页面中,我需要阅读母版页内的用户控件属性。能否请您建议如何完成。
【问题讨论】:
在您的内容页面上试试这个
YourControl YourControlObj = this.Master.FindControl("YourControl") as YourControl;
【讨论】:
在母版页中 -
<asp:TextBox Id="txt" />
在内容页面中 -
TextBox t = this.Master.FindControl("txt") as TextBox;
t.Text = "Some Value";
【讨论】:
<my:UControl Id="uc" /> 在内容页中 - UControl t = this.Master.FindControl("uc") as UControl; // You can use property now. 。
看看有没有帮助
Literal mpLiteral = (Literal) Master.FindControl("masterPageLiteralControlID");
【讨论】:
这样做
在母版页中
<uc1:MyWebUserControl ID="myCtl" runat="server" ClientIDMode="Static" />
在内容页面中(在代码后面)
MyWebUserControl myWCtl = this.Master.FindControl("myCtl") as MyWebUserControl;
【讨论】: