【C#.NET】C#用户控件的使用
1.用户控件本身就是一种特殊控件,完全可以像其他控件那样拖放到页面上。
2.以编程方式访问用户控件
在页面中加入以下语句访问用户控件:
TextBox tb = Userlogin1.FindControl("txtUserID") as TextBox;
if(tb!=null)
tb.Text="编程快乐";
或者在用户控件中设置一个Public 的字段对外提供访问:2.以编程方式访问用户控件
在页面中加入以下语句访问用户控件:
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/None.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](https://www.cnblogs.com/Images/OutliningIndicators/ExpandedBlockEnd.gif)
Userlogin1.sUserName = "编程快乐ing";
由于安全原因,更改密码框(TextMode="Password"的TextBox控件)的Text属性将没有任何效果。