工作小结(十)-控件赋值(checkboxlist,textbox)
2009-07-22 18:25
204 查看
1.对checkboxlist赋值
由于checkboxlist在前台绑定了一个objdatasource,所在必须在控件的事件中进行赋值
protected void chkBranchCode_PreRender(object sender, EventArgs e)
2 {
3 if (!String.IsNullOrEmpty(Request["ID"]))
4 {
5 TblsysITSLeader leader = tblsysITSLeader.loadDataSet_NH(Request["ID"]);
6 if (leader != null)
7 {
8 if(!String.IsNullOrEmpty(leader.BranchCodeList))
9 {
10 string[] strList = leader.BranchCodeList.Split(',');
11 for (int i = 0; i < strList.Length; i++)
12 {
13 foreach (ListItem li in chkBranchCode.Items)
14 {
15 if (li.Value == strList[i].ToString())
16 {
17 li.Selected = true;
18 }
19 }
20 }
21 }
22 }
23 }
24 }
2.TextBox控件TextMode=Password时赋值
因为TextBox编译之后是Input,利用Input的Value赋值方法实现.
<asp:TextBox ID="txtPassword" runat="server" TextMode="password" MaxLength="30"></asp:TextBox>
赋值的时候:
txtPassword.Attributes.Add("Value", "1234");
注意存在以下几个问题:
1.输入中文不支持
2.查看源文件,仍能看到密码
由于checkboxlist在前台绑定了一个objdatasource,所在必须在控件的事件中进行赋值
protected void chkBranchCode_PreRender(object sender, EventArgs e)
2 {
3 if (!String.IsNullOrEmpty(Request["ID"]))
4 {
5 TblsysITSLeader leader = tblsysITSLeader.loadDataSet_NH(Request["ID"]);
6 if (leader != null)
7 {
8 if(!String.IsNullOrEmpty(leader.BranchCodeList))
9 {
10 string[] strList = leader.BranchCodeList.Split(',');
11 for (int i = 0; i < strList.Length; i++)
12 {
13 foreach (ListItem li in chkBranchCode.Items)
14 {
15 if (li.Value == strList[i].ToString())
16 {
17 li.Selected = true;
18 }
19 }
20 }
21 }
22 }
23 }
24 }
2.TextBox控件TextMode=Password时赋值
因为TextBox编译之后是Input,利用Input的Value赋值方法实现.
<asp:TextBox ID="txtPassword" runat="server" TextMode="password" MaxLength="30"></asp:TextBox>
赋值的时候:
txtPassword.Attributes.Add("Value", "1234");
注意存在以下几个问题:
1.输入中文不支持
2.查看源文件,仍能看到密码
相关文章推荐
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件(textbox,button,lable,radio,checkbox,selected)的取值、赋值
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- 工作小结-TextBox为密码框赋值技巧,CSS溢出显示省略号方法
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- 工作小结-TextBox为密码框赋值技巧,CSS溢出显示省略号方法
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- Jquery主要控件的取值、赋值,包括textbox,button,lable,radio,checkbox,selected
- ASP.NET服务器端控件RadioButtonList,DropDownList,CheckBoxList的取值、赋值用法
- [导入]在服务器端得到CheckBoxList控件最后选择项的方法