ASP and hidden textBox

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I've a webPage, which has a checkbox.
i want that when the checkbox is checked, a textbox will be created and
showen under the checkbox.
How can i do it?

Thanks,
Gidi.
 
Hi,

I've a webPage, which has a checkbox.
i want that when the checkbox is checked, a textbox will be created and
showen under the checkbox.
How can i do it?

Thanks,
Gidi.

Place a textbox in a div or span on your page with the style set to
display: none. On the checkbox clientside clickevent run a java script
to reset the display.

function SwitchDiv()
{
document.getElementById('TextBoxIDName').style.display='block'
}

Remember that it will revert back to its original state upon postback.

OR

if you want to use the postback, set the property on your textbox to
visible=false and on the postback clickevent from the checkbox set the
property to visible=true
 
Hi,

Gidi said:
Hi,

I've a webPage, which has a checkbox.
i want that when the checkbox is checked, a textbox will be created and
showen under the checkbox.
How can i do it?
My suggestion is that the Textbox be always there, just invisible ( using
Textbox.Visible = false;)
so when the checkbox is checked you change it to visible

like this:

<asp:CheckBox runat="Server" ID="ChangeLocationCHK" Checked="false"
AutoPostBack="true"
OnCheckedChanged="ChangeLocation_Checked"
Text="Change Agent Location" />


<asp:TextBox runat="Server" ID="NewCodeTXT" visible="false"></asp:TextBox>


in the code behind:


protected void ChangeLocation_Checked(object sender, EventArgs e)
{
NewCodeTXT.Visible = ChangeLocationCHK.Checked;



}
 
Back
Top