Link to home
Start Free TrialLog in
Avatar of nmotion
nmotionFlag for United States of America

asked on

Validating an embedded user control at the same time as the parent validation

I have a user control that I've drag-and-dropped onto an .aspx page.  Within this user control is a method called Validate.  Because it's possible to drop more than one instance of the user control on this page, the validate method requires the specific name of the instance passed into it... basically it'd be called Validate(NameOfInstance).

Unfortunately, when I click the Submit button on the .aspx page the validation on the .ascx control isn't handled (thus creating the need for the Validate method to begin with).  It seems that ASP.NET, after page load, handles page validation on the client-side without postback.  Thus I don't see a way to tap into the aspx page's Page_Validate handler (if there is even such a thing) to call the user control's Validate method.

I think my approach is to use javascript on the aspx page to call the Validate method of the user control.  I don't mind if it does a postback.  I just need for it to validate everything on the page at once instead of validating everything on the aspx page, then seeing my Validate() call in the button click handler and executing that (so you see one set of red asterisks on the aspx page, then once valid you'll see the red asterisks for the user control).

I hope I've been clear and thank you kindly in advance!
Avatar of prairiedog
prairiedog
Flag of United States of America image

Are you using the built-in validators for the user control or the custom validator?
Avatar of nmotion

ASKER

At the moment I'm using the built-in validators on the user control.  And they're nothing fancy.  Just required field validators.
ASKER CERTIFIED SOLUTION
Avatar of prairiedog
prairiedog
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial