Hi experts
i want to set enter key . . in my webpage i have 35 textboxe's .. in cntrol i moved with TAB key . . but i want to move with also Enter Key . . any suggestion guy . .
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Suthish NairPosted Apr 14, 2011, 7:23 AM
refer
BrianPosted Jun 8, 2011, 9:35 AM
I figured out the answer to my question. If you are using a Silverlight Application and want to use the "Enter" key to tab through TextBoxes or Controls you can do something similar to the following:
private void OnKeyDown(object sender, KeyEventArgs e) controls = LayoutRoot.Children().Where(x => x.GetType().Name == "TextBox" || x.GetType().Name == "ComboBox").OrderBy(y => y.TabIndex).ToList();
{
if (e.Key == Key.Enter)
{
List
int indx = controls.IndexOf(e.OriginalSource as Control);
if (indx < 0 && e.OriginalSource == btn && e.Key == Key.Enter) { // Do what you need here; // return; }
if (indx + 1 >= controls.Count) { btn.Focus(); }
else { controls[indx + 1].Focus(); }
}
// Another additional add on you could use is to implement what the "Esc" key press will do as seen below
if (e.Key == Key.Escape) { // Do what you need here; }
}
In my example I am not only using the "Enter" key to simulate a "Tab" key press, I am also counting the Controls so that when the last control is hit the "Enter" key press takes you to an "OK" button and pressing "Enter" again will click the "OK" button thus submitting a form, login control, etc.
BrianPosted Jun 7, 2011, 1:55 PM
Prabhakar PariharPosted Apr 14, 2011, 7:29 AM
Prabhakar PariharPosted Apr 14, 2011, 7:01 AM
Ravishankar SinghPosted Apr 14, 2011, 5:48 AM
Could you please elaborate more?so that we can understand your question with your requirement.