Click to See Complete Forum and Search --> : RegularExpressionValidator on 1 button
doomsday123
February 6th, 2006, 02:59 PM
What I am doing is validating for a textbox that I have on my page. On the same page I have some login textboxes as well. What is happening is I have some asp:RegularExpressionValidator's that are validating the information in the textbox that has nothing to do with the login but when I am trying to click the login button on my site it still validates the textbox on the bottom of the page so i have to fill that textbox out before i can log in. Anyone know how to get around this? Thanks.
ITGURU
February 7th, 2006, 01:43 AM
Dear doomsday123,
If your Login control does not attached to any validation control then you can simply set CausesValidation Property of your Login Button to False.
When you set this property (CausesValidation) of button to false it will not perform the functionality of the validation controls on your page.
doomsday123
February 7th, 2006, 11:17 AM
When I set CauseValidation to false in the image button that keeps trying to validate the textboxes it has nothing to do with I get this error.
Page.IsValid cannot be called before validation has taken place. It should be queried
in the event handler for a control that has CausesValidation=True and initiated the
postback, or after a call to Page.Validate.Anyone know why?
ITGURU
February 7th, 2006, 11:01 PM
Dear doomsday123,
This error occurred because in your Login button event (the button in which you set the CausesValidation = False), you have used Page.IsValid, which you can only used in the case of controls which causesvalidation = true.
So, please remove any line which contains Page.IsValid in your Image Button Event at server Side.
doomsday123
February 8th, 2006, 03:00 PM
There is no event in the code behind for this button. Here is how I have the button setup.<asp:imagebutton runat="server" id="LoginButton" CommandName="Login" AlternateText="login" skinid="login" CssClass="button" CausesValidation="false" />Any reason why it would still be doing this?
ITGURU
February 8th, 2006, 10:48 PM
Dear doomsday123,
It is clear from your HTML declaration that you have some event in the Code behind file for your Image Button because you have specified CommandName attribute for the button which mean you have some associated Command Event of the Image.
If still you does not have any event attached to the Image button then just check whether anywhere you used Page.IsValid either in Code behind or in ASPX Page. If Page.IsValid is found anywhere in your code then bypass usage of Page.IsValid when user press your Image Button.
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.