Prevent Web Form from posting back

M

marcia

In a Web Form with a Button and a TextBox, when I type
some characters in the TextBox (AutoPostBack == false) and
then hit the Enter key on the keyboard, the Web Form goes
to the server (as though I had pressed the Button). I want
the Form to go to the server when the Button - and not the
Enter key - is pressed.

???
 
G

George Ter-Saakov

That is the browser behavior.
You can avoid this but not having submit button (input type="submit").
Instead have a regular button (input type="button").


George.
 
M

marcia

My button needs to be an ASP.NET (Web Form) Button. Is
there a solution in this situation?
 
G

George Ter-Saakov

Here is the Browser rule (which is not related to ASP.NET at all ).

If user pressed enter then FORM is submitted if there is type="SUBMIT"
button. Or type="IMAGE" is present in the FORM.

So instead of WebControl button add HtmlControl button (which is under HTML
tab in the toolbox).

Then give it a try.


George.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top