不在母版页中应用css [英] Not applying css in master page

查看:39
本文介绍了不在母版页中应用css的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我的母版页上有一个asp文字控件。关于该控件的文字,我附上了

< link type =text / css =stylesheethref =〜/ css / skin.css> 但是即使我尝试在Page_Init,Page_PreRender和最初的page_load事件中应用此控制文本,此链接也不应用css。



请建议我在哪里可以进行更改。

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.

推荐答案

编写你的代码

写skin.css代码

检查它...



如果这个工作那么你的路径不正确
write your code
write skin.css code
check it...

if this is working then You path is not correct


你好chintan在这里你可以把你现有的例子发给我,因为我想要看看你在表格中如何应用css的方式
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


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.


这篇关于不在母版页中应用css的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆