views:

98

answers:

1

I am building a set of asp.net server controls and in one of them, essentially a container control, I want to add a form control, a script manager and an update panel. Is this possible or will I have to create these in a Page base class that I have for the web project for page/control life cycle reasons?

I am not using master pages.

Regards, Andrew

+1  A: 

ASP.NET allows only one form on the page. When you create controls, they are used on a page. You need a Page object to add controls to. This is why controls like the form and ScriptManager (who can only have one instance on a page) are put on the Page itself, or on the masterpage (if you have one). Putting them in a control would provide the opportunity to have two instances on the page, which would not work.

Slavo
Yeah, it's what I've normally done before but I have a requirement to do this programmatically, I favour the Masterpage like you say though or even doing it on a page base class.I was just wondering if was "possible" to do this all in a server control, I need to be more solid on life cycle events to be honest! Even if a second form was added it couldn't happen anyway as the Page checks it's "_fOnFormRenderCalled" field and raises an exception if a form has already added.
Knoxy