Using OpenFileFialog in asp.net web

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,

I am creating a web application in asp.net in which I have to show an
openfiledialog box to select the file and display the selected file with its
path in a text box.
I try to solve this problem with the System.Windows.Forms.OpenFileFialog.

I use

Imports System.Windows.Forms

In the sub the code is like...

Dim ofd As OpenFileDialog = New OpenFileDialog

If ofd.ShowDialog() = DialogResult.OK Then
txtPath.Text = ofd.FileName()
End If


I get the following Error.


It is invalid to show a modal dialog or form when the application is not
running in UserInteractive mode.Specify the ServiceNotification or
DefaultDesktopOnly style to display a notification from a service application.

What should I do to get the openfiledialog box to appear?
Where can I Specify the ServiceNotification?
Is it possible at all to use the System.Windows.Forms base in a Web form?

I'm not that familiar with asp.net.

Many thanks!
 
Hi Willem,

You can't use Windows component, such as OpenFileDialog,
on web server-side. You may use HtmlInputFile, HTML <input
type= file> element, to select file on client-side.

Hope it helps,

Elton Wang
(e-mail address removed)
 
Thats easy!

Many thanks

Willem
-----Original Message-----
Hi Willem,

You can't use Windows component, such as OpenFileDialog,
on web server-side. You may use HtmlInputFile, HTML <input
type= file> element, to select file on client-side.

Hope it helps,

Elton Wang
(e-mail address removed)

a
service application.
.
 
Back
Top