Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
Please help me out.
my query is
now cruser on particular control.when user press the enter button cruser should be focus particular control

i am entering something in text box suddenly i press enter button the crusser should be on that text box
Posted
Comments
Deepak_Sharma_ 20-Apr-12 2:03am    
Its a Windows application or Web application

Sorry to say but i am unable to understand your query

Will you please elaborate a little more?

So that i try to help you.
 
Share this answer
 
Comments
Pradhan Gagan 20-Apr-12 2:18am    
my text box inside the gridview.if user enter date wrongly he pressed the enter button .That cruser should be keep the particular text control
hi try this,


JavaScript
<input id="textbox" type="text" onkeypress="return myScript(event)" />

//Add control on which you want to focus,for example:
<input id="targetTxtBox" type="text"/>

//Javascript function:


function myScript(e) {
    if (e.keyCode == 13) {
        var tb = document.getElementById("targetTxtBox");
        tb.focus(); 
        return false;
    }
}
 
Share this answer
 
Comments
Pradhan Gagan 20-Apr-12 2:17am    
yes i got but my text box inside of gridview.how i will place this code
Lalit PB 21-Apr-12 5:01am    
you want to set focus on textbox after postback or at client side it self?
Hi..

For example you want cursor on text box.

Nametxt.Focus();


on page load or any other event
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900