![](/img/trans.png)
[英]How to detect if ASP.NET control properties contain DataBinding expressions?
[英]How to Init properties of another control asp.net
我在asp.net中有2個Web用戶控件:control1 control2
control1包括以下屬性:
<script runat="server">
public string MacName = "UNKOWN";
</script>
<h1><%= MacName %></h1>
control2包含后面的代碼:
protected void Page_Load(object sender, EventArgs e)
{
control1 newControl = ((control1)Page.LoadControl("~/controls/control1.ascx"));
newControl .[some code here]
somePanel.Controls.Add(newControl);
}
我想知道如何從control1 MacName初始化屬性。
我懷疑這實際上不是在創建類成員:
<script runat="server">
public string MacName = "UNKOWN";
</script>
相反,將其作為類級屬性放在代碼后方:
class control1
{
public string MacName { get; set; }
// etc.
}
然后,您應該能夠在該類型的任何實例上進行設置:
newControl.MacName = "some value";
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.