日期:2014-05-20 浏览次数:20544 次
<table width="100%" border="0" cellpadding="0" cellspacing="10">
<%
foreach (YM.Model.SystemSetting model in systemSettingList)
{
%>
<tr>
<td style="height: 16px; width:100px" align="right"><%=model.SystemKey%>:</td>
<td style="height: 16px; width:270px;" align="left">
<input id="TextBox_<%=model.SystemID %>" name="TextBox_<%=model.SystemID %>" type="text" value="<%=model.SystemValue %>" class ="box1" onfocus="this.className='box2'" onblur="this.className='box1'" style ="width:260px;" maxlength="200"/>
</td>
<td align="left" class="notes">注:<%=model.SystemExplain%></td>
</tr>
<%
}
%>
</table>
protected void btnClear_Click(object sender, EventArgs e)
{ foreach (Control ctl in this.Controls)
{ this.txtClear(ctl);
}
} #endregion
private void txtClear(Control ctls)
{
if(ctls.HasControls())
{
foreach (Control ctl in ctls.Controls)
{
txtClear(ctl);
}
}
else
{
if (ctls.GetType().Name == "TextBox")
{
TextBox tb = new TextBox();
tb = (TextBox)this.FindControl(ctls.ID); //这里是清空所有的值,你想赋什么值直接改tx.Text即可.
tb.Text = ""; }
else if (ctls.GetType().Name == "DropDownList")
{ DropDownList ddl = new DropDownList();
ddl = (DropDownList)this.FindControl(ctls.ID);
ddl.SelectedIndex = 1;
}
}
}