您的位置:首页 > 其它

工作小结(十)-控件赋值(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.查看源文件,仍能看到密码
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐