Using OpenFileFialog in asp.net web

Discussion in 'ASP .Net' started by =?Utf-8?B?V2lsbGVt?=, Jan 30, 2005.

  1. 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!
     
    =?Utf-8?B?V2lsbGVt?=, Jan 30, 2005
    #1
    1. Advertising

  2. =?Utf-8?B?V2lsbGVt?=

    Elton Wang Guest

    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



    >-----Original Message-----
    >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!
    >.
    >
     
    Elton Wang, Jan 30, 2005
    #2
    1. Advertising

  3. =?Utf-8?B?V2lsbGVt?=

    Willem Guest

    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
    >
    >
    >
    >>-----Original Message-----
    >>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!
    >>.
    >>

    >.
    >
     
    Willem, Jan 30, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Patrick
    Replies:
    2
    Views:
    681
    Steven Cheng[MSFT]
    Oct 1, 2004
  2. Guadala Harry
    Replies:
    9
    Views:
    434
    Guadala Harry
    Nov 6, 2004
  3. Navin Mishra
    Replies:
    4
    Views:
    402
    =?Utf-8?B?UGVyc2hpbmc=?=
    Oct 20, 2006
  4. dev648237923
    Replies:
    3
    Views:
    545
    Steven Cheng[MSFT]
    Feb 9, 2007
  5. Replies:
    0
    Views:
    1,819
Loading...

Share This Page