How can I include additional markup within a 'Content' inner property within an ASP.Net WebControl?

Posted by GenericTypeTea on Stack Overflow See other posts from Stack Overflow or by GenericTypeTea
Published on 2010-04-30T16:01:20Z Indexed on 2010/04/30 16:27 UTC
Read the original article Hit count: 385

I've searched the site and I cannot find a solution for my problem, so apologies if it's already been answered (I'm sure someone must have asked this before).

I have written a jQuery Popup window that I've packaged up as a WebControl and IScriptControl. The last step is to be able to write the markup within the tags of my control. I've used the InnerProperty attribute a few times, but only for including lists of strongly typed classes.

Here's my property on the WebControl:

[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public something??? Content
{
   get
   {
      if (_content == null)
      {
         _content = new something???();
      }
      return _content;
   }
}
private something??? _content;

Here's the HTML Markup of what I'm after:

   <ctr:WebPopup runat="server" ID="win_Test" Hidden="false" Width="100px" Height="100px"
      Modal="true" WindowCaption="Test Window" CssClass="window">
      <Content>
         <div style="display:none;">
            <asp:Button runat="server" ID="Button1" OnClick="Button1_Click" />
         </div>
         <%--Etc--%>
         <%--Etc--%>
      </Content>
   </ctr:WebPopup>

Unfortunately I don't know what type my Content property should be. I basically need to replicate the UpdatePanel's ContentTemplate.

EDIT: So the following allows a Template container to be automatically created, but no controls show up, what's wrong with what I'm doing?

[PersistenceMode(PersistenceMode.InnerProperty)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ITemplate Content
{
    get
    {
        return _content;
    }
    set
    {
        _content = value;
    }
}
private ITemplate _content;

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about html