Click here to Skip to main content
15,895,656 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi all,

I have a asp literal control on my master page. On that control's text I attached
<link type="text/css" rel="stylesheet" href="~/css/skin.css" > but this link is not applying css even if I tried to apply this control text in Page_Init,Page_PreRender,And Initially on page_load events.

Please suggest me where i can make changes.
Posted
Comments
CodeBlack 23-Aug-13 4:21am    
can you update your question with Code for Literal Control ?

write your code
write skin.css code
check it...

if this is working then You path is not correct
 
Share this answer
 
hi chintan here can you send me your existing example to me because i want to check out the way how you applying css in your form
 
Share this answer
 
XML
Hi all thanks for your time and suggestion...
I got the solution. I was applying css on literal's text property in Page_PreRender event.
So that in rendered output of page link was displayed like this: &lt;link type="text/css" rel="stylesheet" href="~/css/skin.css" &gt; so that css path was not getting found.
Solution for this is:
<pre lang="cs">protected void Page_Init(object sender, EventArgs e)
    {
        //litSkinStyle.Text = Common.auto_version(&quot;css/skin.css&quot;);
        var link = new HtmlLink();
        link.Href = Common.auto_version(&quot;css/skin.css&quot;);
        link.Attributes.Add(&quot;rel&quot;, &quot;stylesheet&quot;);
        link.Attributes.Add(&quot;type&quot;, &quot;text/css&quot;);
        Page.Header.Controls.Add(link);
    }</pre>

Now I'm giving relative path which is correctly rendered in output and css is applied.
I used this way because I have done auto version of css.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900