Microsoft KB Archive/813822

= BUG: The first enabled Button control receives the RaisePostBack event when the ENTER key is pressed =

Article ID: 813822

Article Last Modified on 4/19/2004

-

APPLIES TO


 * Microsoft ASP.NET 1.1
 * Microsoft ASP.NET 1.0

-





SYMPTOMS
After a TextBox control handles the RaisePostBack event, the first enabled Button control also receives the RaisePostBack event.



CAUSE
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.



WORKAROUND
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 %>



public void Page_Load(object s, EventArgs e) { //Validate; if (Page.IsValid) Response.Write(&quot;Valid&quot;); }

 

 Fill in a value! 



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.

Keywords: kbbug KB813822

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.