如何在后台代码中设置和获取用户控件中的子控件的属性?
2006-05-19 14:44
633 查看
>>>1、如何在后台代码中设置和获取用户控件中的子控件的属性?
add public properties/methods in your codebehind class for your usercontrol and declare in your page class:
protected YourUserControlCodeBehindClass YourUserControlID;
..
if you don't have a codebehind class, you can always do
UserControl c = (UserControl)FindControl("YourUserControlID");
TextBox tb = (TextBox) c.FindControl("YourTextBoxIDInYourUserControl);
tb.Text = "123";
>>>2、如何在后台设置和获取用户控件本身的属性?
if you have a codebehind class for your usercontrol, you can do
protected YourUserControlCodeBehindClass YourUserControlID;
YourUserControlID.Property1 = "123";
otherwise, you have to use Reflection
add public properties/methods in your codebehind class for your usercontrol and declare in your page class:
protected YourUserControlCodeBehindClass YourUserControlID;
..
if you don't have a codebehind class, you can always do
UserControl c = (UserControl)FindControl("YourUserControlID");
TextBox tb = (TextBox) c.FindControl("YourTextBoxIDInYourUserControl);
tb.Text = "123";
>>>2、如何在后台设置和获取用户控件本身的属性?
if you have a codebehind class for your usercontrol, you can do
protected YourUserControlCodeBehindClass YourUserControlID;
YourUserControlID.Property1 = "123";
otherwise, you have to use Reflection
相关文章推荐
- 牛腩购物9 用户表设计/动软生成器/金钱字段decimal(18, 2)/ 注册的时候的前台js判断/后台代码判断/正则表达式软件/RegexBuddy/设置数据库字段的唯一性约束/如何获取控件在前台html的id值/如何将C#的后台正则换成js的正则
- 如何把动态的用户控件转换成合适的类型并设置其属性
- 客户端的javascript改变了asp.net webform页面控件的值,后台代码中如何获取修改后的值。
- asp.net 在后台给前台的控件设置Style属性与坐标,后台设置CSS样式,后台获取前台控件坐标
- Flex中如何通过设置restrict属性在TextInput控件中限制用户可以输入的字符串的例子
- web控件在.aspx页面中在.aspx.cs后台代码Page_Load()中都设置了相同的属性,哪个优先级高?
- winfrom 安装包如何在代码中设置安装路径,而不需要获取[TARGETDIR]属性来获取
- asp.net在后台给前台的控件设置Style属性与坐标,后台设置CSS样式,后台获取前台控件坐标
- 当控件设置disabled="disabled"属性时,后台不能获取修改后的值
- SilverLight学习笔记--如何在xaml文件中操作用户在后台代码定义的类(2)--示例篇:创建一个登录控件(原创)(转载本文请注明出处)
- asp.net 在后台给前台的控件设置Style属性与坐标,后台设置CSS样式,后台获取前台控件坐标
- asp.net 在后台给前台的控件设置Style属性与坐标,后台设置CSS样式,后台获取前台控件坐标
- 如何在后台代码获取控制EditItemTemplate的控件
- asp.net在后台给前台的控件设置Style属性与坐标,后台设置CSS样式,后台获取前台控件坐标
- 代码中获取控件的宽高度,代码中设置控件的Margin
- 如何获取 XAML 控件的模板代码
- Asp.net 2.0 自定义控件开发专题讲解[为用户控件增加DataSource属性, 能够自动识别不同数据源](示例代码下载)
- 如何在xaml文件中操作用户在后台代码定义的类(1)
- TreeView控件如何设置节点显示与隐藏,主要是用来做后台权限,没有权限的就隐藏,有权限的就显示?
- android中如何在代码中直接设置View的layout_weight属性