Library tutorials & articles
Making skinned custom controls
- Overview
- The base class - SkinControl
- A simple sample control
- Using the sample control
Using the sample control
In order to use the sample control on a page all you need to do is add a @Register directive to the assembly: <%@ Register TagPrefix="MySite" Namespace="MySite.Controls" Assembly="MySite" %>
And to add the actual control to the page: <MySite:SampleControl SkinVirtualPath="SampleSkin.ascx" runat="server"/>
The property SkinVirtualPath is optional, but I thought I'd just show you how you can easily override the default skin for a control.
And of course you need to create a skin - here is an example: <%@ Control Language="C#" %>
<asp:label id="Label1" cssclass="header" runat="server"/><br/>
<asp:repeater id="Repeater1" runat="server">
<itemtemplate><%# Container.DataItem %></itemtemplate>
<separatortemplate>, </separatortemplate>
</asp:repeater>
Well that's it basically – I hope you've enjoyed reading this.
Related articles
Related discussion
-
Using FedEx Web Service to Calculcate Shipping Cost
by bhora123 (4 replies)
-
Very Urgent regarding deleting the images from a folder
by rameshbandi (2 replies)
-
Dynamically Generating PDFs in .NET
by nike12 (10 replies)
-
New style of Javascript used in extenders.
by mittalpa (0 replies)
-
Not able to launch the web application
by NaseemAhmed (0 replies)
Related podcasts
-
StackOverflow uses ASP.NET MVC - Jeff Atwood and his technical team
Scott chats with Jeff Atwood of CodingHorror.com and most recently, StackOverflow.com. Jeff and Joel Spolsky and their technical team have created a new class of application using ASP.NET MVC. What works, what doesn't, and how did it all go down?
You have successfully plundered the concepts contained in the asp.net forums without offering anything new, or really showing the reader why they would want to use them
Not to mention your wonderful coding practice of catch {}
What happens if the InitialiseSkin method makes calls to controls that don't exist on the skin? The skin is just not going to load, it won't show the user any helpful message. You're forgetting the skills of the average developer probably don't encompass debugging stack traces which don't get rethrown.
Nice one.
This thread is for discussions of Making skinned custom controls.