Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / April 2006

Tip: Looking for answers? Try searching our database.

Custom template in a LinkButton

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
eebster@newsgroups.nospam - 09 Apr 2006 21:08 GMT
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
Steven Cheng[MSFT] - 10 Apr 2006 07:59 GMT
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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.