templated control default

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

  1. Amit Patel

    Amit Patel Guest

    Hello,
    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>
    </custom:myControl>

    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?

    i.e.:
    <file>
    <aHeader>this is the defined default header</aHeader>
    </file>

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

  2. "Amit Patel" <> wrote in message
    news:094601c3680b$85e54530$...
    > Hello,
    > 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>
    > </custom:myControl>
    >
    > 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?


    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
    Internet Engineer
    John Saunders, Aug 21, 2003
    #2
    1. Advertising

  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

    nm

    "Amit Patel" <> wrote in message
    news:094601c3680b$85e54530$...
    > Hello,
    > 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>
    > </custom:myControl>
    >
    > 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?
    >
    > i.e.:
    > <file>
    > <aHeader>this is the defined default header</aHeader>
    > </file>
    >
    > Any help is appreciated. Thanks in advance!
    neil m, Sep 9, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. RA Scheltema
    Replies:
    3
    Views:
    399
    RA Scheltema
    Jan 6, 2004
  2. Marijn
    Replies:
    5
    Views:
    456
    Marijn
    Feb 13, 2004
  3. Replies:
    0
    Views:
    2,227
  4. Amadeus W. M.
    Replies:
    2
    Views:
    392
    Amadeus W. M.
    Jul 4, 2006
  5. Replies:
    1
    Views:
    304
Loading...

Share This Page