Advertisement

05.27.2008 at 12:15PM PDT, ID: 23435994
[x]
Attachment Details

How to select a file in a web app

Asked by wsturdev in Visual Studio .NET 2005

Tags: VB.Net, Web app, Standard File Dialog

I have a web app and am working in VB.Net.  

On one of the pages of my web site, I need to allow the user to select a file, after which I will import the data and work with it.  I already have the import logic working, but now I need logic to present the typical file dialog to allow the user to select the file.

I have attached the code I am having trouble with -- it needs to simply ask the user to locate and select a file.  If the user does so, I will store the complete path in "Import_FileLabel"

I have so far tried the attached code, but am getting an error:

"Showing a modal dialog box or form when the application is not running in UserInteractive mode is not a valid operation. Specify the ServiceNotification or DefaultDesktopOnly style to display a notification from a service application."

How do I modify the code to work, or alternatively, what code should I be using?Start Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
Protected Sub Select_a_Template_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Select_a_Template.Click
        Dim openfile As New Windows.Forms.OpenFileDialog
 
        openfile.CheckFileExists = True
        openfile.CheckPathExists = True
        openfile.Filter = "Excel Files (*.xls)|*.xls|Other Files|*.*"
        openfile.ShowDialog()
 
        If openfile.FileName <> "" Then
            Me.Import_FileLabel.Text = openfile.FileName.ToString()
        Else
            Me.Import_FileLabel.Text = "No file currently selected."
        End If
    End Sub
 
Loading Advertisement...
 
[+][-]05.27.2008 at 01:37PM PDT, ID: 21655478

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 04:38PM PDT, ID: 21656566

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.27.2008 at 05:36PM PDT, ID: 21656823

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Studio .NET 2005
Tags: VB.Net, Web app, Standard File Dialog
Sign Up Now!
Solution Provided By: wsturdev
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906