Microsoft Knowledge Base Article
This article contents is Microsoft Copyrighted material.
©2005-©2007 Microsoft Corporation. All rights reserved.
Terms
of Use |
Trademarks
Article ID: 813822 - Last Review: April 19, 2004 - Revision: 1.3
BUG: The first enabled Button control receives the RaisePostBack event when the ENTER key is pressed
After a
TextBox control handles the
RaisePostBack event, the first enabled
Button control also receives the
RaisePostBack event.
When a Microsoft ASP.NET page has several
Button controls, followed by a
TextBox control, followed by more
Button controls after the
TextBox control, when you enter text in the text box and then you press ENTER, the
TextBox control receives the
RaisePostBack event. The first enabled
Button control will always get the
RaisePostBack event after the ENTER key has been pressed on the client side even though the ENTER key that is pressed is handled by another control.
To work around this problem, insert the following code in your ASP.NET page, and then modify it to fit your particular application requirements.
You cannot call the
Page.IsValid property before validation has occured. Query the
Page.IsValid property in the event handler for a control when the value of the
CausesValidation property is True or after the
Page.IsValid method has been called.
<%@ page %>
<script runat=server language=c#>
public void Page_Load(object s, EventArgs e)
{
//Validate();
if (Page.IsValid)
Response.Write("Valid");
}
</script>
<form runat=server>
<input type=text runat=server id=mytext>
<input type=submit runat=server>
<asp:RequiredFieldValidator id="RequiredFieldValidator1"
ControlToValidate="mytext"
Display="Static"
InitialValue="" Width="100%" runat=server>
Fill in a value!
</asp:RequiredFieldValidator>
</form>
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.
APPLIES TO
- Microsoft ASP.NET 1.1
- Microsoft ASP.NET 1.0
Community Feedback System
Very often, it takes hours to solve a problem. Very often, you've looked high
and low, and have tried a lot of solutions. When you finally found it, chances
are, it was because someone else helped you. Here's your chance to give back.
Use our community feedback tool to let others know what worked for you and what
didn't.
Please also understand that the community feedback system is not warranted to be
correct, it's simply a system that we've built to let people try and help each
other. If something in a feedback response doesn't make sense to you, or you're
not comfortable making changes that the feedback talks about (like registry
edits), please consult a professional.
Thank you for using kbAlertz.com Feedback System.
-- Scott Cate
|
Anonymous User
|
|
| Written:
4/27/2004 4:01 AM |
|
|
|
Anonymous User
|
|
| Written:
4/27/2004 4:27 AM |
|
|
|
Anonymous User
|
|
| Written:
4/27/2004 6:20 AM |
|
|
|
Anonymous User
|
|
| Written:
4/27/2004 7:29 AM |
|
|
|
Syed Jamshaid Akhter
- shahjee7 NOSPAM-AT-NOSPAM wol.net.pk
|
|
| Written:
4/27/2004 9:55 AM |
|
|
|
Wayne Sellars
- wsellars NOSPAM-AT-NOSPAM cfwebmasters.com
|
|
| Written:
4/27/2004 10:43 AM |
|
|
|
Ray Cheung
- cheura NOSPAM-AT-NOSPAM canada.com
|
|
| Written:
4/27/2004 3:19 PM |
|
|
|
Anonymous User
|
|
| Written:
4/27/2004 3:56 PM |
|
|
|
Tom
|
|
| Written:
4/30/2004 1:50 PM |
|
|
|
Shaji
|
Reported as Irrelevant
|
| Written:
5/4/2004 11:21 PM |
|
|