The HTML is as follows:
CopyCode The Code is as follows: <tr>
<TD class = "lefttd" style = "width: 0000px"> additional amount </TD>
<TD style = "width: 315px"> <asp: textbox id = "txtextendmoney" text = "0" runat = "server"> </ASP: textbox>
<Asp: regularexpressionvalidator id = "regextend" runat = "server" controltovalidate = "txtextendmoney" display = "dynamic" errormessage = "Incorrect format" validationexpression = "[1-9] \ D *\. \ D * | 0 \. \ D * [1-9] \ D * | ^ [1-9] \ D * | 0 "> </ASP: regularexpressionvalidator>
<Asp: requiredfieldvalidator id = "reqextedno" runat = "server" controltovalidate = "txtextendmoney" display = "dynamic" errormessage = "cannot be blank"> </ASP: requiredfieldvalidator> </TD>
<TD class = "lefttd"> settlement method </TD>
<TD> <asp: dropdownlist id = "ddlpaytype" runat = "server"> <asp: listitem> cash </ASP: listitem> <asp: listitem> bank transfer </ASP: listitem> </ASP: dropdownlist> </TD>
</Tr>
<Tr>
<TD class = "lefttd"> settlement account </TD>
<TD colspan = "3"> <asp: radiobuttonlist id = "rdbpayaccountbank" runat = "server" repeatlayout = "flow"> </ASP: radiobuttonlist> </TD>
</Tr>
The listitem of the last radiobuttonlist is "Other accounts". When elected, the corresponding Asp.net Server Control is added. Remove the control when selecting another one.
Add
Introduce jquery and then use the following code:
Copy code The Code is as follows:/* settlement method */
$ (": Radio: Last"). BIND ("click", function (){
If ($ ("# txtbanknew"). Length = 0 ){
$ (This ). parent (). append ('<span id = "span"> <label style = "margin-left: 6px; margin-Right: 4px; "For =" txtbanknew "> bank account </label> <input runat = 'server' id = 'txtbanknew' type = 'text'/> <label style =" margin-left: 6px; margin-Right: 4px; "For =" txtaccountnew "> account opening </label> <input type = 'text' id = 'txtaccountnew 'runat = 'server'/> </span> ');
};
$ ("# Txtbanknew"). Focus (). Select ();
});
$ (": Radio: Not (: Last)"). BIND ("click", function (){
If ($ ("# txtbanknew"). length> 0 ){
$ ("# Span"). Remove ();
}
});
It is worth noting that if the control after append is a server control with the runat = "server" attribute, the original single quotation marks will automatically become double quotation marks after being generated as the source, and runat = "server" disappears. This is actually consistent with the process of manually writing the DOM structure. NET Framework on the foreground. Open the source file on this page and you can see the following:
Unfortunately, the server control still does not work ......
You can hide the server control -!