templated control default

Discussion in 'ASP .Net Building Controls' started by Amit Patel, Aug 21, 2003.

  1. Amit Patel

    Amit Patel Guest

    I've created a templated control in C#, and I am trying to
    have default values for templates if the user of the
    control does not specify. For example, if the aspx code
    should look like:

    <custom:myControl runat="server" id="control1">
    <aHeader>a non-default Header</aHeader>

    How can i have a default <aHeader> if the user does not
    specify it? Is there any way I could have a separate
    template file with the default values?

    <aHeader>this is the defined default header</aHeader>

    Any help is appreciated. Thanks in advance!
    Amit Patel, Aug 21, 2003
    1. Advertisements

  2. Your aHeader property is of type ITemplate. All you have to do is set it to
    your default if you find it to be null at the time you go to render it. You
    can do this with the LoadTemplate method:

    if (aHeader == null)
    aHeader = LoadTemplate("default.ascx");
    John Saunders, Aug 21, 2003
    1. Advertisements

  3. Amit Patel

    neil m Guest

    i want to create a templated control for a toolbar and menu. where can i
    read more about this. i found one article on msdn, but i was pretty
    confusing. any ideas? thanks

    neil m, Sep 9, 2003
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.