?
Solved

ASp.Net 2.0 How can i assign Theam/Skin to userconrol

Posted on 2006-07-07
5
Medium Priority
?
265 Views
Last Modified: 2007-12-19
How can i assign Theam/Skin to userconrol ?
I want to assgn the it in usercontrol itself at codebehind.
is it possible?

I need it very urgently...............

Thanx in advance  
0
Comment
Question by:Pratima Pharande
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 16

Expert Comment

by:Swapnil Piparia
ID: 17056668
Hi pratima_mcs,

There is no need to apply themes and skins explicitly in asp.net web user control bcoz its apply automatically, as its container is the page whose parent page is main master page.    

Regards,
NetSwap
0
 
LVL 27

Accepted Solution

by:
Chinmay Patel earned 500 total points
ID: 17056689
Hi There,

User Controls don't have a theme property, but when you assign a theme to a page, the theme does influence all of the controls in the page. A user control uses the theme of its page.

If the theme includes CSS files, then ASP.NET will link to the CSS files. Any styles inside the CSS that are applicable to classes, names, and markup in the user control will style the user control.

If the theme includes skins, then the skins will skin the appropriate controls inside of user controls. For instance, if you have defined a default skin for Calendar controls, then any Calendar controls inside your user control will have that skin applied.

It is also possible to apply a skin directly to the user control, we just need to know a couple tricks. First, let's define a simple user control: MyWidget. MyWidget just renders a Message property.


<%@ Control Language="C#" CodeFile="MyWidget.ascx.cs" Inherits="MyWidget" %>
<h1><%= Message %></h1>

The CodeFile for the control declares a Message property, but more importantly, adds a Themeable attribute 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, we just need a .skin file. We need to @ Register our control, and then write the skin just like we'd write any other skin.


<%@ Register Src="~/MyWidget.ascx" TagName="MyWidget" TagPrefix="otc" %>

<otc:MyWidget Message="Sahil Looks Funny" runat="server" />

Now, anytime we drop MyWidget on a page, the skin file will set a default message (assuming the control's page has a theme selected).

Regards,
Chinmay
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses
Course of the Month9 days, 9 hours left to enroll

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question