When does inputting an HTML message tag return?

I have a couple of asp.net pages with TextBox controls. Some of them return to input (inside the TextBox control), while others do not. For life, I can’t understand why or why not ...

I do not think this has anything to do with asp.net. Do not use ajax etc. I tried playing with a very simple html page and still can not understand.

Perhaps inside or not inside the <form> tag? But all my asp: textbox controls are in the standard form tag, and some do and some don't. Not related to autoPostback from what I see.

EDIT:

An example of markup that triggers a message:

<html> <body> <form> <input type=text /> </form> </body> </html> 

I have asp.net pages that certainly don't publish. The code is extensive and I cannot understand why not.

EDIT2:

How can I prevent postback?

+4
source share
3 answers

If you have only one text field and this does not happen, you can always put hidden input into the form.

 <html> <body> <form> <input type="text" ></input> <input type="text" style="visibility:hidden"></input> </form> </body> </html> 

I tried this in IE7 and FF3 and it works.

+5
source

Typically, most web browsers find that the form has only one text field and will automatically submit the form when the button is clicked.

If you have multiple text fields or multiple forms, the behavior changes. ASP.Net has a "defaultButton" mechanism for buttons, that is, you can specify which button is the submit button for this panel if you press the enter key. You can check this post for more information on setting up forms to submit correctly.

As mentioned in Boo, this will not be caused by multi-line text fields.

If the behavior is really crappy in your form between browsers, you may need to look at the javascript solution to catch the pressed enter key and manually submit the form via javascript.

+2
source

If the text box control is set to autostart, it will return for every keystroke (thus allowing the TextChanged event to fire).

Then the text fields for which their Multiline value is set to false will be returned to Enter .. what actually happens is a representation of the form determined by the behavior in the browser.

Boxes that have multi-line set to true will not cause the form to be sent to Enter.

0
source

All Articles