posted on Friday, July 09, 2004 11:01 PM by warstar

Please Submit when i press enter button :D

Hey all,

Got the following way from one of the old(er) blogs around here but forgot witch.
So here we go i have a Button i want to submit when someone presses Enter :D
This is the way to do it add the following code to your code behind:

Page.RegisterHiddenField("__EVENTTARGET", "The_Name_Of_The_Button");

Just replace The_Name_Of_The_Button with the name of the button :P

Edit:
One of the things also possible is that if your in a textbox and you want that someone presses enter and it will submit you can use:

TextBox1.Attributes.Add("OnKeyUp","if(event.keyCode==13) window.location.href='/gotoUrl.aspx'");

Happy netting,
Warnar

Comments