Javascript for onfocus

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • raghulvarma
    New Member
    • Oct 2007
    • 90

    Javascript for onfocus

    Hello Friends,

    I have developed a web page using c#. My problem is that as the page gets loaded I am not able to get the cursor to the specified textbox,how should I do that using java script?plz some one help me out
    thanks in advance
    raghul
  • Ramchandar
    New Member
    • Dec 2007
    • 11

    #2
    Hi,
    On body load call a javascript function to set the focus to the textbox u desire.
    <body onload="javascr ipt:setfocus(); ">

    Or simply set the focus to the textbox like this

    <body onload="documen t.getElementByI d('txtUser').fo cus();">

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      I believe in visual studio there's a property that you can set that tells a control to be the defaul focus (which means that visual studio will produce the javascript code, that mentioned previously, for you)

      Comment

      Working...