Monday, 5 September 2011

Set Focus On Text Box when Page Load

Hi Question arises in our mind is how to default focus to a asp control when the page loads  . First way is use the javascript other is given below
  This is another extremely simple thing that can be done without resorting to writing JavaScript.  If you only have a single textbox (or two) on a page why should the user have to click in the textbox to start typing?  Shouldn't the cursor already be blinking in the textbox so they can type away?
Using the DefaultFocus property of the HtmlForm control you can easily do this.
<body>
  <form id="frm" DefaultFocus="txtUserName" runat="server">
    <!--Write your page code here-->
  </form>
</body>

Hope this will benificail for all

No comments:

Post a Comment