views:

91

answers:

2

I am working with someone else's code. The code was originally designed so that data would dynamically create controls (and sub-controls of those controls...) on the OnInit event on numerous web control panels. And then later validation methods would check those dynamically created controls for valid data. This continues to work just fine for my web site. However, I need to be able to validate that data without my website (as in this will just be server side). The simpilist solution appeared to be to just have the panels initialize and then run the validation methods. That'd be great...if I could figure out how to initialize those panels server side without a web page.

Can this be done? Is there any way to get a panel to initialize without having a page to display that panel?

Thanks

A: 

Try RenderControl.

Kon
Sadly....I couldn't figure out how to get RenderControl to trigger the OnInit
Eves
A: 

That way lies madness - you could use reflection to call the control's InitRecursive method, but it needs a Page (among other things) to run correctly.

You should extract the validation code into a new class that you can call from your server code an change your WebControl to use that class as well.

Jeff Sternal
Rather than move the validation code I am first going to try moving the code that is in OnInit which creates the controls to separate functions and then call that before I validate.
Eves
The validation logic has to be in another class so that you aren't dependent on the ASP.NET infrastructure to use it.
Jeff Sternal