Tuesday, October 30, 2012

Set autofocus to textbox in asp.net using HTML5

In previous versions of html we don't have direct property to set the auto focus to desired control.If we want to do this things,we have to use java script ,jquery etc.But the HTML5 provides set of new attributes to make easy such kind of things. Here i will set the auto focus to input control using AUTOFOCUS attribute in HTML5.Below are the examples for both patterns
In asp.net Each control has a method to set the auto focus property.Here tb name is textbox id.
Here i have taken two input controls for name and comments.Then set the autofoucs to name text box.
<label for="name">Enter your name : </label> 
<input autofocus="autofocus" type="text" /><br />
<label for="Comment">Enter your comments : </label> 
<input type="textarea" /><br />

No comments: