473,505 Members | 13,904 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Response.Redirect not working when pressing the Enter key

Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.

At the very top of our main page I provide a TextBox and a Button for
submitting Google searches. Recently somebody pointed out to me that
you can't just press ENTER anymore after typing in the TextBox but
that you HAVE to click on the submit Button WITH THE MOUSE for it to
work. After some initial troubleshooting I discovered that it's only
an issue in IE 6 & 7 (works fine in FireFox!).

To simplify I created a brand new empty web form. I dropped an
<asp:TextBox/& <asp:Button/control on the the page (even made sure
they had the same ValidationGroup="google") and then wired up the
Button's click event.

protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?q=" +
TextBox1.Text);
}

If you click the submit Button using the mouse the Response.Redirect
works fine. If you press ENTER on the keyboard while the focus is
still in the TextBox it does not work (the page just flashes/posts
back).

Let me clarify that the code in the Button1_Click event handler DOES
execute in both situations. Meaning if I put a breakpoint on the
Response.Redirect line and then run the debugger; when I type some
text into the TextBox and press ENTER on the keyboard the breakpoint
DOES get hit. When I step-out however, the page just refreshes and is
still sitting there. It's like the code is actually running ok and the
redirect is being sent to the client, but IE is then stopping it from
happening at the client-side somehow!? Alternatively, if I type into
the TextBox then do a SHIFT+TAB to put the focus on the submit button
itself, THEN pressing ENTER works.

How can I make it so that someone can type some text into a TextBox
and then just press ENTER on the keyboard? Anybody have any ideas?
Please?

Thanks in advance,
-Nick

Feb 14 '07 #1
4 7605
Try using the DefaultButton attribute of the form tag. Here is an example
that I used for a login page I wrote:

<form id="form1" runat="server" defaultbutton="btnSubmit"
defaultfocus="txtUsername">

The DefaultButton is the ID of the Button you want "clicked" when the user
presses enter, and the DefaultFocus is the TextBox the the cursor is
initially in when the page first loads. Good Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<nk****@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.

At the very top of our main page I provide a TextBox and a Button for
submitting Google searches. Recently somebody pointed out to me that
you can't just press ENTER anymore after typing in the TextBox but
that you HAVE to click on the submit Button WITH THE MOUSE for it to
work. After some initial troubleshooting I discovered that it's only
an issue in IE 6 & 7 (works fine in FireFox!).

To simplify I created a brand new empty web form. I dropped an
<asp:TextBox/& <asp:Button/control on the the page (even made sure
they had the same ValidationGroup="google") and then wired up the
Button's click event.

protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?q=" +
TextBox1.Text);
}

If you click the submit Button using the mouse the Response.Redirect
works fine. If you press ENTER on the keyboard while the focus is
still in the TextBox it does not work (the page just flashes/posts
back).

Let me clarify that the code in the Button1_Click event handler DOES
execute in both situations. Meaning if I put a breakpoint on the
Response.Redirect line and then run the debugger; when I type some
text into the TextBox and press ENTER on the keyboard the breakpoint
DOES get hit. When I step-out however, the page just refreshes and is
still sitting there. It's like the code is actually running ok and the
redirect is being sent to the client, but IE is then stopping it from
happening at the client-side somehow!? Alternatively, if I type into
the TextBox then do a SHIFT+TAB to put the focus on the submit button
itself, THEN pressing ENTER works.

How can I make it so that someone can type some text into a TextBox
and then just press ENTER on the keyboard? Anybody have any ideas?
Please?

Thanks in advance,
-Nick

Feb 14 '07 #2
On Feb 13, 11:11 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
Try using the DefaultButton attribute of the form tag. Here is an example
that I used for a login page I wrote:

<form id="form1" runat="server" defaultbutton="btnSubmit"
defaultfocus="txtUsername">

The DefaultButton is the ID of the Button you want "clicked" when the user
presses enter, and the DefaultFocus is the TextBox the the cursor is
initially in when the page first loads. Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

<nko...@gmail.comwrote in message

news:11**********************@m58g2000cwm.googlegr oups.com...
Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.
At the very top of our main page I provide a TextBox and a Button for
submitting Google searches. Recently somebody pointed out to me that
you can't just press ENTER anymore after typing in the TextBox but
that you HAVE to click on the submit Button WITH THE MOUSE for it to
work. After some initial troubleshooting I discovered that it's only
an issue in IE 6 & 7 (works fine in FireFox!).
To simplify I created a brand new empty web form. I dropped an
<asp:TextBox/& <asp:Button/control on the the page (even made sure
they had the same ValidationGroup="google") and then wired up the
Button's click event.
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?q=" +
TextBox1.Text);
}
If you click the submit Button using the mouse theResponse.Redirect
works fine. If you press ENTER on the keyboard while the focus is
still in the TextBox it doesnotwork (the page just flashes/posts
back).
Let me clarify that the code in the Button1_Click event handler DOES
execute in both situations. Meaning if I put a breakpoint on the
Response.Redirectline and then run the debugger; when I type some
text into the TextBox and press ENTER on the keyboard the breakpoint
DOES get hit. When I step-out however, the page just refreshes and is
still sitting there. It's like the code is actually running ok and the
redirect is being sent to the client, but IE is then stopping it from
happening at the client-side somehow!? Alternatively, if I type into
the TextBox then do a SHIFT+TAB to put the focus on the submit button
itself, THEN pressing ENTER works.
How can I make it so that someone can type some text into a TextBox
and then just press ENTER on the keyboard? Anybody have any ideas?
Please?
Thanks in advance,
-Nick- Hide quoted text -

- Show quoted text -
Hey thanks for the help! Your suggestion led me down the right path to
fixing the problem, or at least patching it.

I tried to use the DefaultButton property on the Form tag but that
didn't work, oddly enough. I then tried wrapping the controls in a
Panel and set the Panel's DefaultButton and that seemed to get it
working in IE.

I am still left wondering what was going wrong... Before I even tried
to set the DefaultButton property it WAS submitting the Form and the
Button1_Click event WAS firing and the Response.Redirect() WAS being
executed on the server. When the WebResponse was recieved by IE it
seems like it just decided to ignore the redirect!? Why did it work
fine with FireFox and not in IE? I would like to understand exactly
what was going on behind the scenes. I hate not understanding why.

Feb 14 '07 #3
I understand how you feel, I usually like to understand the reasons for what
happens as well. I cannot say I know the answer to your question, but it
sounds to me like it might be partially browser related, since you are
mentioning both IE and FireFox. However, I do not have much experience when
it comes to the differences in the most popular browsers. It might also help
both me and other people trying to help you with this problem if you posted
your exact code. Although it is not very efficient, an alternative attemp to
solving your problem (although I have never tried it) would be to use the
JavaScript onKeyPress event to detect when the Enter key is pressed, and
execute the JavaScript form1.submit() method if event.keyCode (if using IE)
or event.which (for other browsers) is the keycode for the Enter key. Good
Luck!
--
Nathan Sokalski
nj********@hotmail.com
http://www.nathansokalski.com/

<nk****@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
On Feb 13, 11:11 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:
>Try using the DefaultButton attribute of the form tag. Here is an example
that I used for a login page I wrote:

<form id="form1" runat="server" defaultbutton="btnSubmit"
defaultfocus="txtUsername">

The DefaultButton is the ID of the Button you want "clicked" when the
user
presses enter, and the DefaultFocus is the TextBox the the cursor is
initially in when the page first loads. Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/

<nko...@gmail.comwrote in message

news:11**********************@m58g2000cwm.googleg roups.com...
Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.
At the very top of our main page I provide a TextBox and a Button for
submitting Google searches. Recently somebody pointed out to me that
you can't just press ENTER anymore after typing in the TextBox but
that you HAVE to click on the submit Button WITH THE MOUSE for it to
work. After some initial troubleshooting I discovered that it's only
an issue in IE 6 & 7 (works fine in FireFox!).
To simplify I created a brand new empty web form. I dropped an
<asp:TextBox/& <asp:Button/control on the the page (even made sure
they had the same ValidationGroup="google") and then wired up the
Button's click event.
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?q=" +
TextBox1.Text);
}
If you click the submit Button using the mouse theResponse.Redirect
works fine. If you press ENTER on the keyboard while the focus is
still in the TextBox it doesnotwork (the page just flashes/posts
back).
Let me clarify that the code in the Button1_Click event handler DOES
execute in both situations. Meaning if I put a breakpoint on the
Response.Redirectline and then run the debugger; when I type some
text into the TextBox and press ENTER on the keyboard the breakpoint
DOES get hit. When I step-out however, the page just refreshes and is
still sitting there. It's like the code is actually running ok and the
redirect is being sent to the client, but IE is then stopping it from
happening at the client-side somehow!? Alternatively, if I type into
the TextBox then do a SHIFT+TAB to put the focus on the submit button
itself, THEN pressing ENTER works.
How can I make it so that someone can type some text into a TextBox
and then just press ENTER on the keyboard? Anybody have any ideas?
Please?
Thanks in advance,
-Nick- Hide quoted text -

- Show quoted text -

Hey thanks for the help! Your suggestion led me down the right path to
fixing the problem, or at least patching it.

I tried to use the DefaultButton property on the Form tag but that
didn't work, oddly enough. I then tried wrapping the controls in a
Panel and set the Panel's DefaultButton and that seemed to get it
working in IE.

I am still left wondering what was going wrong... Before I even tried
to set the DefaultButton property it WAS submitting the Form and the
Button1_Click event WAS firing and the Response.Redirect() WAS being
executed on the server. When the WebResponse was recieved by IE it
seems like it just decided to ignore the redirect!? Why did it work
fine with FireFox and not in IE? I would like to understand exactly
what was going on behind the scenes. I hate not understanding why.

Feb 15 '07 #4
On Feb 14, 12:56 pm, nko...@gmail.com wrote:
On Feb 13, 11:11 pm, "Nathan Sokalski" <njsokal...@hotmail.comwrote:


Try using the DefaultButton attribute of the form tag. Here is an example
that I used for a login page I wrote:
<form id="form1" runat="server" defaultbutton="btnSubmit"
defaultfocus="txtUsername">
The DefaultButton is the ID of the Button you want "clicked" when the user
presses enter, and the DefaultFocus is the TextBox the the cursor is
initially in when the page first loads. Good Luck!
--
Nathan Sokalski
njsokal...@hotmail.comhttp://www.nathansokalski.com/
<nko...@gmail.comwrote in message
news:11**********************@m58g2000cwm.googlegr oups.com...
Hi, I've been going crazy trying to figure out what's wrong with our
Asp.Net 2.0 intranet site.
At the very top of our main page I provide a TextBox and a Button for
submitting Google searches. Recently somebody pointed out to me that
you can't just press ENTER anymore after typing in the TextBox but
that you HAVE to click on the submit Button WITH THE MOUSE for it to
work. After some initial troubleshooting I discovered that it's only
an issue in IE 6 & 7 (works fine in FireFox!).
To simplify I created a brand new empty web form. I dropped an
<asp:TextBox/& <asp:Button/control on the the page (even made sure
they had the same ValidationGroup="google") and then wired up the
Button's click event.
protected void Button1_Click(object sender, EventArgs e)
{
Response.Redirect("http://www.google.com/search?q=" +
TextBox1.Text);
}
If you click the submit Button using the mouse theResponse.Redirect
works fine. If you press ENTER on the keyboard while the focus is
still in the TextBox it doesnotwork (the page just flashes/posts
back).
Let me clarify that the code in the Button1_Click event handler DOES
execute in both situations. Meaning if I put a breakpoint on the
>Response.Redirectline and then run the debugger; when I type some
text into the TextBox and press ENTER on the keyboard the breakpoint
DOES get hit. When I step-out however, the page just refreshes and is
still sitting there. It's like the code is actually running ok and the
redirect is being sent to the client, but IE is then stopping it from
happening at the client-side somehow!? Alternatively, if I type into
the TextBox then do a SHIFT+TAB to put the focus on the submit button
itself, THEN pressing ENTER works.
How can I make it so that someone can type some text into a TextBox
and then just press ENTER on the keyboard? Anybody have any ideas?
Please?
Thanks in advance,
-Nick- Hide quoted text -
- Show quoted text -

Hey thanks for the help! Your suggestion led me down the right path to
fixing the problem, or at least patching it.

I tried to use the DefaultButton property on the Form tag but that
didn't work, oddly enough. I then tried wrapping the controls in a
Panel and set the Panel's DefaultButton and that seemed to get it
working in IE.

I am still left wondering what was going wrong... Before I even tried
to set the DefaultButton property it WAS submitting the Form and the
Button1_Click event WAS firing and the Response.Redirect() WAS being
executed on the server. When the WebResponse was recieved by IE it
seems like it just decided to ignore the redirect!? Why did it work
fine with FireFox and not in IE? I would like to understand exactly
what was going on behind the scenes. I hate not understanding why.- Hide quoted text -

- Show quoted text -
Can you please submit the code of how did you wrap the controls in a
panel. I have similar problem that with IE the response.redirect() is
not working but with Firefox it does.
- Sourik

Mar 7 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
12378
by: Bill | last post by:
I have a page that contains processed variables that I'd like to forward using the response.redirect method. However, because the response.redirect contains the page within "pagename.asp", I have...
3
3886
by: Paul | last post by:
I'm not getting the results I want when I use Response.Redirct in a ASP page. I enter this line of code in a asp page from domain1.com. Response.Redirect...
5
2140
by: john | last post by:
Hello, One our thrid page for some reason the response.redirect isn't working on the live server. It works fine on the development machine but when we move the code to the live server it doesn't...
6
2886
by: Keith Patrick | last post by:
I have to do some programmatic redirects (in several pages) based on URLs I am given from an external source. The URLs have querystrings at the end, but one in particular is about 240 chars long,...
1
2690
by: Sospeter | last post by:
Hi Ken, I have done that but still experiencing same problem. Tried the following i.e. turning smartnavigation = false and using server.transfer as below but nothing works. Please help. ...
10
1461
by: Johnny Fugazzi | last post by:
I have a couple of pages that have started showing an odd problem. When the code calls Response.Redirect("file.aspx"), nothing happens. The page goes white, and the old URL and querystring are...
5
2121
by: ODAN | last post by:
We are testing a ASP.NET application in Visual Studion 2003 and written in C#. One of the pages that register new users on this application fails to redirect to another page when the button is...
2
2030
by: Nathan Sokalski | last post by:
The last two lines of code in the Click event of a Button Control on my page are: Me.WelcomeEmail() Response.Redirect("mainmenu.aspx") The last line of code in Me.WelcomeEmail() is:
7
3310
by: =?Utf-8?B?bGxldmk=?= | last post by:
Hi there. I have a simple web page ( 1 textbox, 1 label, 1 button). The page runs under IIS, but it takes at least a minute before it allows me to enter keystrokes after pressing ctl+f5....
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7098
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5610
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.