aspx:
<INPUT style="Z-INDEX: 121; LEFT: 240px; WIDTH: 208px; POSITION: absolute; TOP: 552px; HEIGHT: 22px" type="file" id="pro_url" runat="server" size="15">
aspx.cs:
this.pro_url.Value = "test/image.gif";出错。。
HtmlInputFile 的值属性是不可设置的。 
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.NotSupportedException: HtmlInputFile 的值属性是不可设置的。之所以用HTML控件file是为了方便用户取得图片的URL时不需要输入,而是通过点击控件上的“浏览”按纽找到图片的位置就可以了,很方便。

解决方案 »

  1.   

    HtmlInputFile 的值属性确实是不可设置的,这是规定
      

  2.   

    不能这样设置, 但可以这样设置啊:this.pro_url.Attributes["value"] = "test/images.gif";
      

  3.   

    this.pro_url.Attributes["value"] = "test/images.gif";
    不行吧
    那有没别的办法来实现类似的功能呢?
      

  4.   

    this.pro_url.Attributes["value"] = "test/images.gif";
      

  5.   

    它的属性是不能设置的,只读的,你可以通过pro_url.PostedFile取得用户选择的文件
      

  6.   

    用模拟键盘输入if (retval.length > 0)
    {
      document.Form1.btn_file.focus();
      document.Form1.btn_file.select();
      var WshShell = new ActiveXObject("Wscript.Shell");

      retval = retval.replace("//","/");
      for (i = 0; i <= retval.length - 1; i++)
      {
        try
        {
    WshShell.SendKeys(retval.substring(i, i+1));
        }
        catch(e)
        {}
       }
       WshShell.Quit; 
    }  其中retval是要往FILE控件中输入的字符串
    原理,先把光标定位在FILE控件上,再全选,再输入文件路径及其路径
      

  7.   

    <input type="file" id="btn_file" name="btn_file" value="test" style="display:none">
    <input type="button" name="btn_abc" value="瀏覽" onclick="F_Open_dialog()"><script language="javascript">
    function F_Open_dialog()
        {
    document.space.btn_file.click();
    tmp_str = document.space.btn_file.value;
    alert(tmp_str);
    document.space.btn_file.value='';
        }
    </script>