繁体   English   中英

访问内容页面内部母版页的用户控件属性?

[英]Accessing user control properties of master page inside a content page?

在项目母版页中,文件后没有代码。 在内容页面中,我需要阅读母版页中用户控件的属性。 能否请您建议如何完成。

在内容页面上尝试一下

YourControl YourControlObj = this.Master.FindControl("YourControl") as YourControl;

在母版页中-

<asp:TextBox Id="txt" />

在内容页面中-

TextBox t = this.Master.FindControl("txt") as TextBox;
t.Text = "Some Value";

看看是否有帮助

Literal mpLiteral = (Literal) Master.FindControl("masterPageLiteralControlID");  

像这样

在母版页中

<uc1:MyWebUserControl ID="myCtl" runat="server" ClientIDMode="Static" />

在内容页面中(在后面的代码中)

MyWebUserControl myWCtl  = this.Master.FindControl("myCtl") as MyWebUserControl;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM