【发布时间】:2010-11-19 14:11:01
【问题描述】:
我希望如果 checkbox1 被选中,那么 textbox45 将可见并且 textbox1 将被禁用..
但我希望 textbox45 将取代 textbox1。
如果我再次选中复选框 1 和复选框 2,那么 textbox1 和文本框 2 将在 asp.net 表的第一行和第二行中可见...怎么做?
【问题讨论】:
我希望如果 checkbox1 被选中,那么 textbox45 将可见并且 textbox1 将被禁用..
但我希望 textbox45 将取代 textbox1。
如果我再次选中复选框 1 和复选框 2,那么 textbox1 和文本框 2 将在 asp.net 表的第一行和第二行中可见...怎么做?
【问题讨论】:
有这样的复选框控件 -
<asp:CheckBox id="checkbox1" runat="server"
AutoPostBack="True"
Text="checkbox1"
OnCheckedChanged="Check1_Clicked"/>
然后,您可以像这样创建文本框控件,然后
<asp:TextBox ID="txtbox1"
visible="false"
runat="server"/>
在 Check1_Clicked 事件上 -
void Check1_Clicked(Object sender, EventArgs e)
{
txtbox1.Visible = False;
txtbox45.Visible = True;
//After controlling the visiblity, you can dynamically position your textbox on your form.
txtbox45.Style("Position") = "Absolute"
txtbox45.Style("Top") = "50px"
txtbox45.Style("Left") = "100px"
// provide suitable values to position the textbox accordingly for all your textboxes
}
【讨论】: