<script>
var txtBox=document.getElementById("ctl00_txtUserName" );
if (txtBox!=null ) txtBox.focus();
</script>
or
functionCheckPromotionalCode(){ var txtControl = document.getElementById('txt'); txtControl.focus(); }
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
That's because, for the most part, they're all saying the same thing. Show your HTML markup as well as where you have that JS code. You might get some better answers then.
<script >
function CheckPromotionalCode() {
document.getElementById("txtName").focus();
}</script>
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
Marked as answer by bhargav panchal on Feb 20, 2012 07:55 AM
if u are using scriptmanager on ur page then u can use that to focus on textbox
like
ScriptManager1.SetFocus(TextBox1)
A.Venkatesan
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
bhargav panc...
Member
219 Points
82 Posts
How to set focus to textbox using javascript?
Feb 20, 2012 05:54 AM|LINK
Hello friends,
Here I have to set focus to textbox using javascript.
I have tried this code but it does not work.
i need your help.
function CheckPromotionalCode() { var txtControl = document.getElementById('<%= txt.ClientID %>'); txtControl.setfocus(); }Bhargav Panchal
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
karthicks
All-Star
32172 Points
5534 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 05:58 AM|LINK
use focus()
function CheckPromotionalCode() {
var txtControl = document.getElementById('<%= txt.ClientID %>');
txtControl.focus();
}
Refer : http://support.microsoft.com/kb/316719
http://www.informit.com/articles/article.aspx?p=101394
Karthick S
madan535
Contributor
3229 Points
1180 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 05:59 AM|LINK
Use this
function CheckPromotionalCode() { var txtControl = document.getElementById('<%= txt.ClientID %>'); txtControl.focus(); }venkatmca008
Participant
1810 Points
341 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 05:59 AM|LINK
please try this...
<script> var txtBox=document.getElementById("ctl00_txtUserName" ); if (txtBox!=null ) txtBox.focus(); </script>Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
Raigad
Contributor
5131 Points
957 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 06:01 AM|LINK
Use this one
function CheckPromotionalCode() { document.getElementById('<%= txt.ClientID %>').focus();Mark as Answer, if the post helped you...
Visit My Blog
bhargav panc...
Member
219 Points
82 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 06:07 AM|LINK
I have tried all but it does not work..
any other solution for this situation..
Bhargav Panchal
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
MetalAsp.Net
All-Star
112752 Points
18373 Posts
Moderator
Re: How to set focus to textbox using javascript?
Feb 20, 2012 06:14 AM|LINK
That's because, for the most part, they're all saying the same thing. Show your HTML markup as well as where you have that JS code. You might get some better answers then.
venkatmca008
Participant
1810 Points
341 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 06:26 AM|LINK
try this...
<script > function CheckPromotionalCode() { document.getElementById("txtName").focus(); }</script>Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com
bhargav panc...
Member
219 Points
82 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 07:58 AM|LINK
I have tried all.
I found that its working in chrome browser but it is not working in mozilla browser?
so any suggstion?
Bhargav Panchal
Please remember to click “Mark as Answer” on the post that helps you. This can be beneficial to other community members reading the thread.
venkatmca008
Participant
1810 Points
341 Posts
Re: How to set focus to textbox using javascript?
Feb 20, 2012 08:08 AM|LINK
if u are using scriptmanager on ur page then u can use that to focus on textbox
like
Microsoft Certified Professional
Please mark the replies as answers if they help or unmark if not.
If you have any feedback about my replies, please contact venkatmca008@gmail.com