页面代码:
<asp:Panel ID="panelOne" runat="server" Visible ="false">
                <asp:Image ID="ImgOne" runat="server" ImageUrl="../images/none.jpg" style="width: 120px; height: 120px" EnableViewState ="false" AlternateText="暂无图片" />
                <asp:FileUpload ID="UpOne" runat="server" Height="21px" Width="180px" />
                   <iframe id="frameOne" visible="false" runat="server" ></iframe>
                </asp:Panel>
cs中load()
   if (!this.IsPostBack)
        {            string oprOne = "document.getElementById('" + this.ImgOne.ClientID + "').src=document.getElementById('" + this.UpOne.ClientID + "').value;document.getElementById('" + this.frameOne.ClientID + "').InnerText=document.getElementById('" + this.ImgOne.ClientID + "').src";
            this.UpOne.Attributes.Add("onchange", oprOne);
        }我现在想在页面刷新的时候FileUpload 之前选择的图片路径不丢失,想用一个隐藏框架把他记下来,一直没搞定,谁帮我整哈,谢谢。

解决方案 »

  1.   

    我在Load中取值:
    this.ImgTwo.ImageUrl = this.frameOne.InnerText;
    但是为空,panelOne已经可见了。
      

  2.   

    viewstate对于这个我自己加的onchange事件,如何赋值?
      

  3.   

    Viewstate,Session,静态变量,隐藏控件,Cookie,都 可以保存
      

  4.   

    如何在这个onchange事件中保存?
     if (!this.IsPostBack) 
            {            string oprOne = "document.getElementById('" + this.ImgOne.ClientID + "').src=document.getElementById('" + this.UpOne.ClientID + "').value;document.getElementById('" + this.frameOne.ClientID + "').InnerText=document.getElementById('" + this.ImgOne.ClientID + "').src"; 
                this.UpOne.Attributes.Add("onchange", oprOne); 
            } 
      

  5.   

                function init()
                {
                var hfFileName=document.getElementById("hfFileName");
                var UpOne=document.getElementById("UpOne");
                    if(hfFileName && UpOne)
                    {alert(hfFileName.value);
                        //UpOne.value=hfFileName.value;
                        UpOne.onchange=setFileName;
                    }
                    
                }
                
                function setFileName()
                {
                var hfFileName=document.getElementById("hfFileName");
                hfFileName.value=this.value;
                }
                window.onload=init;
                </script>
                <asp:FileUpload ID="UpOne"  runat="server" />
                <asp:HiddenField ID="hfFileName" runat="server" />file   The   value,   a   file   name,   typed   by   the   user   into   the   control.   Unlike   other   controls,   this   value   is   read-only. input file 的value是只读的
      

  6.   


    顶,楼主的想法很好,但实现不了, <asp:FileUpload  ... 生成的 <input type="file" ...., 其value是只读的,不能设置不能修改。
      

  7.   

    一个静态的变量static  存起来,然后在读取,sesion很多啊,都可以,慢慢来
      

  8.   

    FileUpload value指只读,估计楼主实现不了了。