Solved

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

Posted on 2008-10-16
5
611 Views
Last Modified: 2012-05-05
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!
0
Comment
Question by:nmotion
  • 2
5 Comments
 
LVL 22

Expert Comment

by:prairiedog
ID: 22767765
Are you using the built-in validators for the user control or the custom validator?
0
 
LVL 1

Author Comment

by:nmotion
ID: 22788708
At the moment I'm using the built-in validators on the user control.  And they're nothing fancy.  Just required field validators.
0
 
LVL 22

Accepted Solution

by:
prairiedog earned 500 total points
ID: 22789148
If you use built-in validator within the user control itself, it will be fired at the same time with the validation on the ASPX page, and you don't need NameOfInstance, it should know how to handle it by itself.
2008-10-23-133035.jpg
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question