Welcome Guest Search | Active Topics | Sign In | Register

Programmatically defining content in a Dialog Options
ibraheem
Posted: Tuesday, January 27, 2009 8:53:28 AM
Rank: Member
Groups: Member

Joined: 1/26/2009
Posts: 13
Hi there,

I can't seem to get my head round defining content in a Dialog programmatically.

Dialog.ContentControl is read-only, and ContentTemplate is only an interface.

I've created and set all properties of the Dialog programmatically but can't seem to get the content creation right. I can see ContentHtml which is no good as I need to dynamically add Controls to the Dialog.

Also of course I've tried to add the child controls directly to Dialog.Controls but they do not show up in the Dialog.

Your help is most appreciated!
eo_support
Posted: Tuesday, January 27, 2009 9:21:38 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,089
Hi,

The interface you saw, ITemplate is usually supplied by ASP.NET complier. ASP.NET complier automatically generates a TemplateBuilder object for each ITemplate property based on your .aspx page. You can do the same with code but it may not be worth it.

The easiest workaround for this is to first put something inside the dialog's ContentTemplate (for example, "Panel1"), then dynamically add controls as child controls to that Panel. This way you avoid dealing with ITemplate all together.

Like any other dynamic control loading scenario, the timing is that your control are loaded is important --- otherwise view state and server event will not work correctly. You can try to create your controls by overriding CreateChildControls, or in your Page_Init. You may also need to call the dialog's EnsureChildControls before calling your code to ensure that "Panel1" is already created.

Hope this helps.

Thanks!
ibraheem
Posted: Tuesday, January 27, 2009 1:36:19 PM
Rank: Member
Groups: Member

Joined: 1/26/2009
Posts: 13
Thank you!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.