Solved

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

Posted on 2008-10-16
5
604 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now