1

I'm having an issue with the OpenFileDialog class, where the OpenFileDialog window will open, but only behind every other application I have running in my OS. I've been hesitant to ask about this, but my search using many different keywords on Google, and searching other forums, has turned up nil. I'm using the following code in a button click event of the button on my web form I want the user to click on to open the file dialog:

Dim fd As New OpenFileDialog()
    Dim strFileName As String = ""
    fd.Title = "Open File Dialog"
    fd.InitialDirectory = "C:\"
    fd.Filter = "All files (*.*)|*.*|All files (*.*)|*.*"
    fd.FilterIndex = 2
    fd.RestoreDirectory = True

    If fd.ShowDialog = DialogResult.OK Then
        strFileName = fd.FileName
    End If

The dialog box opens - it just opens behind every other window...what am I missing here? Am I just going to have to do a funky workaround by minimizing everything when I call the OpenFileDialog class? All I need is for the window to show in front of the browser and every other window. Thanks in advance for your help!

4

1 回答 1

2

openfiledialog在标准的 ASP.NET 应用程序中没有位置。如果您调用ShowDialog它,对话框将在服务器计算机上打开(在哪个用户会话下?),用户查看客户端上的浏览器窗口时并不知道。

使用<input type="file" ...FileUpload服务器控件让用户选择要上传到服务器的文件。

于 2013-06-03T20:05:10.853 回答