focusing problem and how to process possible simutanious input?

I am going to develop a testing system: when user scanned the badge, the bar code scanner will return a string (ended with a carriage return). Also, user can type in the badge number using keyboard and press "Enter" key. My questions are:
1. How to put focus of the returned string from bar code scanner to my text box area on the page? (focusing problem)
2. Is there a simple way to implement: whenever there is a "return" action, system will begin processing? i.e. either when the user scanned the badge successfully(so the bar code reader will return a string ended with "enter"), or user typed in the number and press "enter" key, system will automatically go to the next step and process the input number in the text box area?  

Thanks a lot!

-Scott
heyday2004Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mmarinovCommented:
Hi heyday2004,

1. for this you have to use javascript method: idoftextbox.focus()
2. check this site : http://www.mag37.com/csharp/articles/DefaultSubmitButton.html?tabid=8

Regards!
B..M
mmarinov
0
surajgupthaCommented:
For 2)

<asp:textbox id="txtScannedNumber" onKeyDown="javascript:checkkeycode()"></asp:textbox>

function checkkeycode()
{
   if (window.event.keycode==13)
      {
         document.form[0].submit();
      }
}
0
AerosSagaCommented:
-----------------------------
set focus
-----------------------------
Private Sub SetFocus(ByVal ctrl As Control)
    ' Define the JavaScript function for the specified control.
    Dim focusScript As String = "<script language='javascript'>" & _
      "document.getElementById('" + ctrl.ClientID & _
      "').focus();</script>"

    ' Add the JavaScript code to the page.
    Page.RegisterStartupScript("FocusScript", focusScript)
End Sub

You can now call the custom SetFocus() function from any event handler to change the control focus as needed:


SetFocus(myTextBox);

--------------------------
submit on enter
--------------------------
MyControl.Attributes.Add("onclick", "javascript:if (event.keyCode == 13) document.Form1.submit();")

Aeros
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.