CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Nov 1999
    Posts
    15

    Textbox question

    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!!

  2. #2
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85
    This code snippet shows you:

    Code:
    if (checkBox1.checked)
    {
     textBox1.Enabled = true;
     textBox1.Focus();
    }
    else
    { 
     textBox1.Enabled = false;
    }
    Hope it helps!

  3. #3
    Join Date
    Nov 1999
    Posts
    15

    No Focus() method for a TextBox...

    I get the following compilation error:

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

    Am I missing something here?

    Thanks!

  4. #4
    Join Date
    Jun 2002
    Location
    Philadelphia, PA
    Posts
    85
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured