By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,946 Members | 697 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,946 IT Pros & Developers. It's quick & easy.

Stopping auto submit...

P: n/a
This one has me perplexed

from vs.net web app

add a new aspx pag
add 3 textbox's and a command butto
in the command buttons click event add response.write "button1 click

from any textbox press the enter ke
the Button1 Click event fire

add a new button, do nothing else except add respnse.write "buttonX click
it's click event might fire but it might be button1.. no real differences to the buttons properties but for some reason (that I can identify)

If anything I would prefer the Enter key to act as a tab key, the only cure I have found is to make the textbox a multiLine textbox. However, I would prefer not to do this, but I can't have someone submitting the form before all the textbox's have entrys (yes I know about fieldvalidators, I would just prefer not to have the it happen and or to have the page do something else

Thanks

Ro
Nov 18 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi Rob,

I'm wondering if you're describing the bug discussed in this article?

http://support.microsoft.com/?kbid=813822

"Rob Lynch" <an*******@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
This one has me perplexed.

from vs.net web app.

add a new aspx page
add 3 textbox's and a command button
in the command buttons click event add response.write "button1 click"

from any textbox press the enter key
the Button1 Click event fires

add a new button, do nothing else except add respnse.write "buttonX click"
it's click event might fire but it might be button1.. no real differences
to the buttons properties but for some reason (that I can identify)

If anything I would prefer the Enter key to act as a tab key, the only
cure I have found is to make the textbox a multiLine textbox. However, I
would prefer not to do this, but I can't have someone submitting the form
before all the textbox's have entrys (yes I know about fieldvalidators, I
would just prefer not to have the it happen and or to have the page do
something else.

Thanks

Rob


Nov 18 '05 #2

P: n/a
Add this event to your text boxes onkeydown="javascript:testForEnter()"

add add this to your page.

<SCRIPT LANGUAGE="javascript">
function testForEnter()
{
if (event.keyCode == 13)
{
event.cancelBubble = true;
event.returnValue = false;
}
}
</SCRIPT>

"Rob Lynch" <an*******@discussions.microsoft.com> wrote in message
news:88**********************************@microsof t.com...
This one has me perplexed.

from vs.net web app.

add a new aspx page
add 3 textbox's and a command button
in the command buttons click event add response.write "button1 click"

from any textbox press the enter key
the Button1 Click event fires

add a new button, do nothing else except add respnse.write "buttonX click"
it's click event might fire but it might be button1.. no real differences to the buttons properties but for some reason (that I can identify)
If anything I would prefer the Enter key to act as a tab key, the only cure I have found is to make the textbox a multiLine textbox. However, I
would prefer not to do this, but I can't have someone submitting the form
before all the textbox's have entrys (yes I know about fieldvalidators, I
would just prefer not to have the it happen and or to have the page do
something else.
Thanks

Rob

Nov 18 '05 #3

P: n/a
Ken

It sure sounds like exactly the same behavour that I have been seeing. It seems like the solution being proposed requires the use of fieldvalidators... There are a couple of fileds that are OK if they are blank, but I still don't want the enter to do the autosubmit

I am going with a combo of what vMike suggests (was doing something ike that and a programatic autotab - for the textbox's that are singleline..

Of course just squeltching the enter via event.returnvalue = false or multiline would be ok, I have decided I will also go the extra 1inch and add an auto tab

Thanks for the effort. I think you found the problem I was seeing

Ro

PS Was my other address a good one?
Nov 18 '05 #4

P: n/a
What I ended up with (and it seems to work quite well) - Thanks All

Code Behind Pag

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Loa
'Put user code to initialize the page her
TextBox1.Attributes.Add("onkeypress", "setEnterKey('TextBox1');"
TextBox2.Attributes.Add("onkeypress", "setEnterKey('TextBox2');"
End Su

Web Pag

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="MailTo.aspx.vb" Inherits="XXXXXXX.MailTo"%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><HEAD><script language="JavaScript"><!-

function setEnterKey(btnName)
if (event.keyCode == 13)
event.cancelBubble = true

if (btnName=="TextBox1")
eval('this.Form1.TextBox2.focus()')

else if (btnName == "TextBox2")
eval('this.Form1.Button1.focus()')

event.returnValue = false

}
//--></script></HEAD><body><form id="Form1" method="post" runat="server"><asp:TextBox id="TextBox1" runat="server"></asp:TextBox><asp:TextBox id="TextBox2" runat="server"></asp:TextBox><asp:Button id="Button1" runat="server" Text="Button"></asp:Button></form></body></HTML>
Nov 18 '05 #5

P: n/a
Hi Rob,
PS Was my other address a good one?


Sorry, no idea. MVPs don't have anything to do with Microsoft's MSDN Managed
Support service except that some of us are also signed up for it as
customers.

Ken

Nov 18 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.