【问题标题】:File Upload and display in a single click文件上传并一键显示
【发布时间】:2014-04-07 02:25:28
【问题描述】:

我想上传一个文件并使用FileUploadbutton 控件在grid 中显示该文件的内容。但我需要通过单击一个按钮来完成这两个事件。我试图隐藏FileUpload 控件,但效果不佳。

以下是我尝试应用的 css 样式定义:

     <div style="height: 89px; width: 620px; position: relative; top: 226px; left: 229px; overflow:hidden">
    <asp:FileUpload ID="FileUpload1" runat="server"
        Style=" top:1px; left:-10px; width: 265px; position: relative; height: 26px; opacity: 0; filter: alpha(opacity=0)"
        Font-Size="30pt" />
    <asp:Button ID="Button1" runat="server" Text="Choose file.."
        Style="top: -5px; left:-265px; z-index: -1; width: 251px; position: relative;"
        Height="22px" />
</div>

这似乎不符合我的目的。

有什么方法可以让我browse the file and display it in single button click

【问题讨论】:

  • didint 明白你的意思..你想单击显示文件浏览器并自动选择任何文件并关闭吗?
  • 我必须先选择一个文件,我使用 Fileupload 控件执行此操作,然后我需要将上传的文件保存到我通过单击按钮执行的 gridview 中。我可以将这两个事件限制为只需单击一次按钮,而不是单击两次

标签: asp.net css file-upload


【解决方案1】:

也许这段代码会有所帮助

uploadButton.Attributes.Add("style", "visibility:hidden");
inputFile.Attributes.Add("onchange", "var uploadControl = document.getElementById('" + uploadButton.ClientID + "'); uploadControl.click();");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-08-30
    • 1970-01-01
    • 1970-01-01
    • 2015-02-21
    • 2016-06-13
    • 1970-01-01
    • 2021-10-31
    相关资源
    最近更新 更多