文件上传并单击即可显示
我想上传文件并使用FileUpload和button控件在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?
回答:
也许这个代码将有助于
uploadButton.Attributes.Add("style", "visibility:hidden"); inputFile.Attributes.Add("onchange", "var uploadControl = document.getElementById('" + uploadButton.ClientID + "'); uploadControl.click();"); 
以上是 文件上传并单击即可显示 的全部内容, 来源链接: utcz.com/qa/258599.html

