Webform中怎么打开一个文件选择对话框啊?我想做一个上传文件的窗口,一个TextBox,两个Button,点一个Button选择要上船的文件,点另一个Button就上传我现在一点选文件的按钮就错误,连显示一个Msgbox都不行:“当应用程序不是以 UserInteractive 模式运行时显示模式对话框或窗体是无效操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。”谢谢啊,还有上传文件我也不会,谁能告诉我一下上传怎么写,拜托了。
如下;<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
<script type="text/javascript">
function openD()
{
document.getElementById("File1").click();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<input id="File1" type="file" style="display:none;"/>
<input type="button" value="open" onclick="openD()" />
</div>
</form>
</body>
</html>
上传文件参考
在“保存”按钮的点击事件中,调用FileUpload控件的SaveAs方法即可上传
if (FileUpload1.HasFile)
{
FileUpload1.SaveAs(Server.MapPath("~") + "/upload/" + FileUpload1.FileName);
}