templated control default

A

Amit Patel

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!
 
J

John Saunders

Amit Patel said:
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");
}
 
N

neil m

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top