Q: The user control does not have the "topic" attribute. How can I apply the topic and skin?
A: The user control does not contain the topic attribute, but allows you to specify a topic for the page. In this way, the topic is applied to all controls on the page, and the user control applies the topic of the page.
If a topic contains a CSS file, ASP. NET points to the CSS file. If the style in the CSS file is used in the user control, these styles are also applied.
If the subject uses skin and the user control contains the controls to be applied by the skin, the controls also apply skin. For example, to define the skin of a calendar control, if your user control contains the calendar control, the calendar control in your user control will also apply this skin.
If you want to develop a skin for the user control, you need some skills. First, define a simple user control: mywidget. mywidget contains the message attribute.
<% @ Control Language = "C #" codefile = "mywidget. ascx. cs" inherits = "mywidget" %>
<H1> <% = message %> This attribute must be declared in the class file, but more importantly, the themeable attribute must be added to the control.
Using system;
Using system. Web. UI;
[Themeable (true)]
Public partial class mywidget: system. Web. UI. usercontrol
{
Private string _ message;
Public String message
{
Get {return _ message ;}
Set {_ message = value ;}
}
}
Finally, you need a. Skin file and add register to. Skin to write and use the skin file.
<% @ Register src = "~ /Mywidget. ascx "tagname =" mywidget "tagprefix =" OTC "%>
<OTC: mywidget message = "Sahil looks funny" runat = "server"/>
Now drag the mywidget to the page, and the skin file will define the message attribute (if the page applies the topic)
Address: http://odetocode.com/Blogs/scott/archive/2006/06/26/4679.aspx
And thanksSaucerFairy Guidance
Note: to create a topic for the server control, you must register the Server Control in the. Skin file again. The method is the same as registering the Server Control in the page file.
Example program download .rar