rahulrcn
rahulrcn

Reputation: 1

how to set the property background image of HTML body in skin file in Asp.Net?

how to set the property background image of HTML body in skin file in Asp.Net?

what I need is I need to change the background image of my page like twitter... but by using skin file...

Upvotes: 0

Views: 5866

Answers (2)

MikeTeeVee
MikeTeeVee

Reputation: 19412

I'm afraid Skin files are for native Asp.net Controls.

One alternative is to generate your CSS on the fly (or have it already made) and load that CSS for the user in the Code-Behind. Simply place this in the Head element of your aspx page/masterpage:

<link id="Custom_StyleSheet" runat="server"
      rel="stylesheet" type="text/css" href="" />

And add this to your Master Page (or regular Aspx page):

protected override void OnInit(EventArgs e)
{
    base.OnInit(e);
    if (IsPostBack == false)
    {
        if (boolUseCustomStyleSheet ==  true)
        {
            //This is the relative path of your Css file.
            Custom_StyleSheet.Href  = sColorCssPath;
        }
    }
}



If you need more fine grain control, you can make <body> a server-side control like so:

Change <body> to :

<body id="someBody" runat="server" >

Then add this to your code-behind:

protected void Page_Load(object sender, EventArgs e)
{
    someBody.Style.Add("background-color", "Silver");
}

I wouldn't recommend the latter approach, but you could have a list of styles to add based on individual user. If it's a finite list of styles, then I'd just create the CSS for each of them and then add them dynamically like in the earlier example.

Upvotes: 0

balexandre
balexandre

Reputation: 75103

You don't set that property in the Skin file but in the Style File

in your style.css under your Theme folder inside App_Themes write the property

body {
    background: url(images/path.png) repeat 0 0;
}

Upvotes: 1

Related Questions