TextBox AutoPostBack=false question (bug?)

G

Guest

Hello,

I have a strange yet very simple problem with the asp.net Textbox web control.

On an empty asp.net page, add a single asp:TextBox control with
Autopostback=false with nothing else on the page.

according to the doc, hitting Enter while the TextBox has focus should do
nothing since Autopostback=false. The problem i have is that it posts the
form (that is, it ignores the Autopostback=false).

Now if i add another textbox to the page, i no longer experience the
problem(???????????).

Is my framework (2.0) corrupted or is anyone else able to reproduce that bug?

Thanks for any help

Renaud

=============
sample page
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default.aspx.vb"
Inherits="_Default" %>
<html>
<body>
said:
</asp:TextBox>
</form>
</body>
</html>
 
G

Guest

Apparently this is the default behavior of an ASP.NET page with only one
textbox on it. For example if there were a page that had a search textbox and
no button to submit the search, you could type in a search term and hit the
ENTER key and the form would be submitted.

There are lots of techniques and new features in ASP.NET 2.0 that let you
customize this type of behavior, such as the "defaultbutton" property of the
FORM element.

But the bottom line is, there's nothing wrong with your Framework - that's
just "the way it is".
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
 
G

Guest

The main problem with this behavior is that it bypasses the control
validations.
If the textbox is a TextBoxValidator, hitting the enter key posts the form
even if the textbox content breaks the validation rules. Validations are
performed correctly on the server side but it's still a useless roundtrip to
the server.

I suppose this could be corrected by using a button on the page. The problem
is, in our application, buttons are replaced by LinkButtons.

Thanks for your quick answer.

Renaud
 
G

Guest

Yes, i solved it by adding a TextBox with display:none

It's not nice but it works...

Thanks

Renaud
 

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,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top