Rank: Advanced Member Groups: Member
Joined: 12/24/2008 Posts: 43
|
Hi
The following does not work during Page_Load
thedialog.ContentHTML = "test"; thedialog.Show();
The dialog is rendered but the content is not. Inspecting the html shows that the body of the iframe is empty.
If I define the ContentTemplate as such:
<ContentTemplate> <asp:Literal ID="testlit" runat="server></asp:Literal> </ContentTemplate>
and then in the Page_Load():
testlit.Text = "test"; thedialog.Show();
or
thedialog.Show(); testlit.Text = "test";
Either way, I get a null reference to the testlit control...
I found a posting on the forum referring to using a Panel control nested in the ContentTemplate, and so I tried that, adding a literal to the panel.
Literal thedialogliteral= new Literal(); thedialogliteral.Text = "test"; thedialogpanel.Controls.Add(thedialogliteral);
Again, no dice, null reference to the panel control...
What am I doing wrong? I assume it is something to do with the page lifecycle and I need to utilise the stage at which the content HAS been rendered, I am just not sure where that is....
I don't really want to create a page to which I pass the content to render and then use the Dialog ContentURL property as that seems a bit long winded.
Kind Regards Sean
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
ContentHtml will work as long as you do not use ContentUrl. These two are mutually exclusive. As long as you use ContentUrl, the dialog renders an iframe. The content of the iframe is solely determined by your ContentUrl and nothing else matters.
To access controls inside the dialog, you would do something like this:
Literal literal = (Literal)Dialog1.ContentContainer.FindControl("testlit"); literal.Text = "test";
This is necessary because the dialog has multiple templates (ContentTemplate and FooterTemplate), so just the ID is not enough to distinguish which one.
Hope this helps.
Thanks!
|
Rank: Advanced Member Groups: Member
Joined: 12/24/2008 Posts: 43
|
Understood.
Problem is that I want to use both contenturl or contenthtml for different purposes on the same page using a shared dialog.
I will just have to use two dialogs, defined the same, but one for contenturl and the other for contenthtml.
Cheers Sean
|