我是这样写的不行啊!!
cs    protected void Page_Load(object sender, EventArgs e)
    {
       string bookid = Request.QueryString["id"].ToString();
       if( bookid.Equals("1234567"))
         {
        this.shenghuo.Style.Add("backgroundColor", "#F2FFF8");
          }
       if( bookid.Equals("0000000"))
         {
        this.shenghuo.Style.Add("backgroundColor", "#ffffff");
          }
     }aspx     <div  id="shenghuo" runat="server" style="width:220px; height:45px; ">
 
       </div>
应该怎么写?请高手给完整代码?谢谢了

解决方案 »

  1.   

     this.shenghuo.Style.Add("background", "#ffffff"); 
      

  2.   

    this.shenghuo.Style.Add("background", "#F2FFF8");
      

  3.   

    你可以在页面放个 隐藏控件
    string bookid = Request.QueryString["id"].ToString(); 
          if( bookid.Equals("1234567")) 
            { 
          hfid.value = "#F2FFF8"; 
              } 
          if( bookid.Equals("0000000")) 
            { 
             hfid.value = "#ffffff"; 
              } 然后在你Onland事件里 用js 去控制控件的背景颜色啦
    ---------------------------------
      

  4.   

    你可以用Attributes解决。
    shenghuo.Attributes.Add("style", " background-color:");
    string bookid = Request.QueryString["id"].ToString(); 
          if( bookid.Equals("1234567")) 
            { 
            //this.shenghuo.Style.Add("backgroundColor", "#F2FFF8");
              shenghuo.Attributes.Add("style", " background-color:#F2FFF8");
              } 
          if( bookid.Equals("0000000")) 
            { 
            //this.shenghuo.Style.Add("backgroundColor", "#ffffff"); 
            shenghuo.Attributes.Add("style", " background-color:#ffffff");          } 
      

  5.   

    this.shenghuo.Style.Add("background-color", "#ccccff;");
      

  6.   

    在JS里面写,根据Request("ID")里面的值进行判断,事件写在body onload 里面
      

  7.   

    你应该看一下id和那个层的id在运行的时候时什么,因为页面运行后.aspx页面会转成html,