我的sytle设置成这样
    <style type="text/css">
    body {background:url(images/<%=Themesurl%>/allbg.jpg) no-repeat right <%=ConfigColor%>;}
    </style>Themesurl和ConfigColor都是在数据库里写好的.
运行显示成功.查看html代码是这样
    <style type="text/css">
    body {background:url(images//allbg.jpg) no-repeat right ;}
    </style>
然后我点击了一个超链接或者其它需要postback的按钮.页面刷新后就没有取到变量值了
html代码成这样了
    <style type="text/css">
    body {background:url(images//allbg.jpg) no-repeat right ;}
    </style>???

解决方案 »

  1.   

    你绑定的‘Themesurl’后台是怎么取得,如果是变量。这个每次刷新都要重新取值的,没有viewstate.
      

  2.   

    运行显示成功.查看html代码是这样
        <style type="text/css">
        body {background:url(images//allbg.jpg) no-repeat right ;}
        </style>
    然后我点击了一个超链接或者其它需要postback的按钮.页面刷新后就没有取到变量值了
    html代码成这样了
        <style type="text/css">
        body {background:url(images//allbg.jpg) no-repeat right ;}
    ================
    两行一样的东西
      

  3.   

    nov30th很细心.谢谢.其实运行是这样的
        <style type="text/css" id="styleconfig">
        body {background:url(images/Themes_2/allbg.jpg) no-repeat right #316c90;}
        </style>
      

  4.   

    scow(怡红快绿之小橙子) ( ) 信誉:100    Blog 
    你好.我都是通过全局变量
        public string Themesurl;
        public string ConfigColor;viewstate写在哪里?
      

  5.   

    就每次取值嘛,不麻烦的话。
    page_load()
    {
    Themesurl = func();
    }
    如果用viewstate,会增加页面大小,多占网络传输带宽。用法
    page_load()
    {
    if(!Page.IsPostBack)
    {
    ViewState["Themesurl"] = func();
    }
    }
    取:Themesurl=ViewState["Themesurl"].ToString();
      

  6.   

    scow(怡红快绿之小橙子) ( ) 信誉:100 
    谢了!我把代码写在ispostback外就行了