unknown postback

  • Thread starter Thread starter Tim Mulholland
  • Start date Start date
T

Tim Mulholland

I have in an ASP.NET page that has one textbox and a button.
I catch the button's click event and do some searching based on the text in
the textbox.
when the user types stuff into the textbox, then uses the mouse to click the
button, or hits tab and hits enter/space to click the button, all goes well.
but if the user stays in the textbox and hits enter, the page posts back,
but doesn't go into the button's click handler.
where is control going? how do i make it go where i want? what event is
being raised?

Thanks in advance!

Tim
 
Hi,

this is problem with IE. It doesn't actually raise any event as you can see,
but this can be handled by attaching say JavaScript handler and having an
action when enter is pressed while in TextBox (INPUT element). There are
also Controls to help with this. See:

http://www.metabuilders.com/Tools/DefaultButtons.aspx

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

I have in an ASP.NET page that has one textbox and a button.
I catch the button's click event and do some searching based on the text in
the textbox.
when the user types stuff into the textbox, then uses the mouse to click the
button, or hits tab and hits enter/space to click the button, all goes well.
but if the user stays in the textbox and hits enter, the page posts back,
but doesn't go into the button's click handler.
where is control going? how do i make it go where i want? what event is
being raised?

Thanks in advance!

Tim
 
its a bug with IE, its supposed send the submit button value. if you only
have one button then the following hack will work.

string script = "<script>if (document.all) document.write('<input
type=hidden name=buttonName>'</script>",
RegisterStartupScript("submithack",script);


-- bruce (sqlwork.com)
 
Is there a solution for this without using this third party control?
I have the same situation (with image buttons)

Thanks,

Aric Levin
 
Thanks a lot for Bruce and Teemu's information on this issue.

Hi Tim and Aric,

As for this problem ,both Bruce and Teemu has mentioned it as a known issue
of the IE. I think we can use some javascript to workaround it, just to set
a certain button on the page as the default button. Here are some tech
articles discussing on this:

http://www.kamp-hansen.dk/pages/showdoc.asp?id=28&menuid=21&menuid=18

http://www.metabuilders.com/tools/DefaultButtons.aspx

http://www.allasp.net/enterkey.aspx

And below is the weblink of a former post in the newsgroup discussing on
the similar issue:
#Subject: <enter> key and form submit
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&threadm=x8Tmqg83
DHA.1992%40cpmsftngxa07.phx.gbl&rnum=3&prev=/groups%3Fhl%3Den%26lr%3D%26ie%3
DUTF-8%26oe%3DUTF-8%26q%3Ddefault%2Bbutton%2Bsteven%2Bcheng

Hope these help.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Get Preview at ASP.NET whidbey
http://msdn.microsoft.com/asp.net/whidbey/default.aspx
 
thanks for all of the information Teemu, Bruce and Steven, i appreciate it.
I havne't implemented any of it yet (i'm in the middle of something else at
the moment) but i'm sure i've got enough info now to get it to work. Thanks!

Tim
 
Back
Top