Need help with skin file for Usercontrol

P

Philipp Lenz

I'm very confused about how this works, all the tutorials out there
show me how to apply a skin to a webcontrol, but I want to know how
I can access the components of a control....for example:

I have a usercontrol, the ascx is defined like this:

<%@ Control Language="C#" AutoEventWireup="true"
CodeFile="Test.ascx.cs" Inherits="Spin.Test" %>

<asp:panel ID="Panel1" runat="server" Height="243px" Width="350px">
<asp:Label ID="header1LBL" runat="server" Height="25px"
Width="100%">Header</asp:Label>
<asp:Label ID="infoLBL" runat="server" Height="25px"
Width="100%">Subheader</asp:Label>
<asp:Label ID="contentLBL" runat="server" Height="100%"
Width="100%"></asp:Label>
</asp:panel>

Now, how can I skin this component in a skin file and tell it to, for
example:

*) Assign a width of 100% to the "Panel1"
*) Make the text for "header1LBL" bold,
*) make the text for "infoLBL" smaller
*) make the background color for "contentLBL" blue

I have registered the usercontrol in my skin file like this:

<%@ Register Src="../../Test.ascx" TagName="Test" TagPrefix="uc1" %>

but beyond that, I'm completely clueless!
Thanks in advance,

Philipp Lenz
 
J

Joshua Flanagan

The controls used within your usercontrol are not directly accessible by
the consuming page. If you want to be able to manipulate the properties
of contained controls (for skinning, etc), you need to make them
available through public properties on the usercontrol.

Add a Width property to your usercontrol which sets the width of the Panel.
Add a HeaderStyle property to your usercontrol which sets the style for
header1LBL.
Add a SubHeaderStyle property to your usercontrol which sets the style
for header1LBL.
Add a ContentStyle property to your usercontrol which sets the style for
header1LBL.

Joshua Flanagan
http://flimflan.com/blog
 

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,769
Messages
2,569,578
Members
45,052
Latest member
LucyCarper

Latest Threads

Top