./res.axd?img=elbow.gif类似这种方式

解决方案 »

  1.   

    .x-elbow {
    float:left;
    height:13px;
    width:18px;
    background:transparent url(./res.axd?img=elbow.gif) no-repeat 0 0
    }
      

  2.   

    路径没有问题的,在测试当中试过了,用ClientScript.GetWebResourceUrl(typeof(类), "图片路径");可以显示出来。
      

  3.   


    试了一下没有用呢,res.axd是指WebResource.axd吧?两个都试过了,显示不出来。
      

  4.   

    我想到解决办法了:
    用一个变量 存ClientScript.GetWebResourceUrl(typeof(类), "图片路径");的值,再将此变量当参数传给你的function,在你的js里,直接引用变量就ok啦
     protected override void RenderContents(HtmlTextWriter output)
            {
                string imgShow = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyServerControl.images.show.jpg");
                string imgHide = this.Page.ClientScript.GetWebResourceUrl(this.GetType(), "MyServerControl.images.hide.jpg");
                //获取组别数组
                getRole(_Nodes);
                foreach (String r in roles)
                {
                    output.AddAttribute(HtmlTextWriterAttribute.Class, "Role");
                    output.RenderBeginTag(HtmlTextWriterTag.Div);
                    output.AddAttribute(HtmlTextWriterAttribute.Src, imgHide);
                    output.AddAttribute(HtmlTextWriterAttribute.Onclick, "change(this,'" + r + "','"+imgShow+"','"+imgHide+"')");
                    output.RenderBeginTag(HtmlTextWriterTag.Img);
                    output.RenderEndTag();
                    output.RenderBeginTag(HtmlTextWriterTag.Strong);
                    output.Write(r);
                    output.RenderEndTag();
                    output.RenderEndTag();                output.AddAttribute(HtmlTextWriterAttribute.Id, r);
                    output.RenderBeginTag(HtmlTextWriterTag.Div);
                    CreatMap(output, r);
                    output.RenderEndTag();
                }
                
                //output.Write(Text);
            } 
    下面是js文件:
    function change(a, b,imageShow,imageHide) {
        var main = document.getElementById(b);
        if (main.style.display == "none") {
            a.setAttribute("src", imageHide);
            main.style.display = "";
        } else {
            a.setAttribute("src", imageShow);
            main.style.display = "none";
        }
    }