Reputation: 11
I am new user at stackoverflow. I am facing issue to set custom focus on certain elements on asp.net. We can use asp.net or java script functionality.
I want to focus on first with page load on payment 1 text box then payment mode 1 dropdown and then save button.
Thank you in advance for your time.
Upvotes: 1
Views: 187
Reputation: 339
You shouldn't need any JS for this. Just use autofocus
<input type="text" name="payment1" tabindex="1" autofocus />
So now on page load that field should be focussed. then tabindex the other fields in the order you want them to focus.
Upvotes: 0
Reputation: 63
You can do all that using HTML and JavaScript:
First assign an id attribute to the payment_1 element. For example (ad "id" to input html element):
<input id="payment1">
Then using JavaScript focus that input field:
document.getElementById('payment1').focus();
If you want your users to have the ability to move between input fields with a "Tab" button in a different order than the default (left to right, up to down), then assign tabindex attribute to elements. For example:
<input id="payment1" tabindex="1">
<button id="save" tabindex="2">
Upvotes: 1
Reputation: 848
You can give the TabIndex
from control property in asp.net or you can use jquery to set focus by $("element").focus()
Upvotes: 1