views:

241

answers:

2

I notice with ASP.NET if the server side control TextBox is used with out autopostback it will not submit (or postback) the form when typed text ends with enter, which is different from the behavior for plain old HTML pages. Fine, I can set autopostback to get the behavior I want after the enter key. However, autopostback will also cause submit (or postback) when the typed text does not end with enter but focus has changed (i.e. with tab or mouse click), which again is different from plain old HTML pages.

How can I get an ASP.NET page to behave the same as a plain old HTML page with respect to text input regardless of whether enter key or change of focus occurs?

A: 

There is some additional setup work, check out this article: http://geekswithblogs.net/ranganh/archive/2006/04/12/74951.aspx

Brian
I wish I knew about the defaultbutton attribute for asp:panel sooner... With it I was able to behavior I wanted. Thanks.
harrije
A: 

There is a HtmlInputText class: http://msdn.microsoft.com/en-us/library/f8kdafb5(v=VS.71).aspx

The behavior you are describing isn't asp.net specific. It's whether you are capturing the enter key in JavaScript and submitting the form. I think the key code for the enter key is 13.

After reading your question again. I'm not sure what you mean when you say "plain old Html page." What behavior are you expecting? ASP.Net output is html.

Chuck Conway
Agreed ASP.NET output is html... By plain out html I was referring to just htmol, no css, no javascript, no preprossesing by ASP.NET... nada.
harrije