Custom template in a LinkButton

E

eebster

Hi,
Im trying to create a custom template in a control derived from a
linkbutton. I want someting like this:

<uc:SortButton id="sortId" runat="server">Column Name
<SortUpTemplate><img src="up.gif"></SortUpTemplate>
<SortDownTemplate><img src="down.gif"></SortDownTemplate>
</uc:SortButton>

Within the SortButton class I have an ITemplate property like this:

private ITemplate __sortDownTemplate = null;
[TemplateContainer(typeof(SortButtonContainer))]
public ITemplate SortDownTemplate
{
get {return __sortDownTemplate;}
set {__sortDownTemplate = value;}
}

If the SortButton control derives from WebControl the SortDownTemplate is
instantiated correctly but if it is derived from a LinkButton they are always
null. Is this not possible?

What Im hoping to achieve is have a generic sort button in which a developer
can define templated areas for the up and down arrows which I can then show
and hide as appropriate to whether the sort order is up or down. Any help
would be appreciated.


Ian
 
S

Steven Cheng[MSFT]

Hi Lan,

Thank you for posting.

Regarding on the custom control developing issue, I think your assumption
of the issue is reasonable, since LinkButton is a well encapuslated control
(which has harded coded some fixed behavior for some certain events), it
will not be the proper type for our custom Template based control. IMO, I
suggest you consider just start your custom control from the "WebControl"
base type. And for the LinkButton , we can reuse it through aggregation
instead of inheritance, that means we can include it in our custom control
as a sub control in the control colleciton and put it in the proper
position in our custom control, also we can register event handler for it
in our custom control conveniently. How do you think of this?

Please feel free to post here if you have any other idea or questions.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top