Click to See Complete Forum and Search --> : Textbox question


kmansari
November 25th, 2002, 12:42 PM
Ok, so I have a textbox sitting right next to a checkbox on a webform. The textbox is disabled and grayed out by default. It needs to be enabled only when the checkbox is checked. No problem so far...

Part 2: This involves positioning the blinking cursor in the textbox, after the textbox has been enabled (saving the user a TAB to get to the textbox.. HUH!) :)

Any ideas how to do this?

Thanks!!

CPCericola
November 26th, 2002, 05:35 AM
This code snippet shows you:


if (checkBox1.checked)
{
textBox1.Enabled = true;
textBox1.Focus();
}
else
{
textBox1.Enabled = false;
}


Hope it helps!

kmansari
November 26th, 2002, 12:36 PM
I get the following compilation error:

'System.Web.UI.WebControls.TextBox' does not contain a definition for 'Focus'.

Am I missing something here?

Thanks!

CPCericola
November 26th, 2002, 12:38 PM
Ah, my mistake for missing the webform. I believe this needs to be done with VBScript and not C# since it will require client-side code. I don't have any examples on this unfortunately.