How to change stylesheet dynamically

Posted by Shoyebaziz123 under Regular Expressions on 6/28/2011 | Points: 10 | Views : 6024 | Status : [Member] | Replies : 2
Hi All,
How can i change the styles of page dynamically at run time , remember there is Master page. i have written this code but its not working

adding a ref link in master page

<link href="<%=GetStyleSheet()%>" rel="stylesheet" type="text/css"/>

there is a folder in which i have style sheets

in code behind i am calling this

protected void Page_Onload(object sender, EventArgs e)
{
tabEmpMaster p = new tabEmpMaster();
p.GetStyleSheet = "~/Styles/SoftGreyGridView.css";
}

GetStyleSheet is a property which i have set like this

public string GetStyleSheet
{
get
{
return mystyle;
}
set
{
mystyle = value;
}
}

any suggestion , Plz.

Thanks




Responses

Posted by: Ndebata on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
You can add runat="server" and set some id="mystyle" then on page int set the required style
<link id="mystyle" runat="server" rel="stylesheet" type="text/css" />

In code behind
protected override void OnInit(EventArgs e)

{
base.OnInit(e);
mystyle.Href = @"css/style.css";
}



Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Lakn2 on: 6/28/2011 [Member] Starter | Points: 25

Up
0
Down
try this

http://forums.asp.net/t/1046389.aspx

Thanks&Regards
LakshmiNarayana Nalluri.

Shoyebaziz123, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response