Making skinned custom controls

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>

Well that's it basically – I hope you've enjoyed reading this.

You might also like...



Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“It works on my machine.” - Anonymous