Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to open a file dialog box (open, save as, new) in asp.net?

Posted on 2003-12-03
7
Medium Priority
?
44,211 Views
Last Modified: 2011-10-03
How to open a file dialog box (open, save as, new) in asp.net?  I know that it is possible in Windows Application. I want to incorporate into web application.
0
Comment
Question by:tgatif
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 4

Expert Comment

by:NetPointer
ID: 9871469
<input id="myFile" type="file" runat="server">

Put above line in your html code..it will generate file and button to browse.
0
 
LVL 2

Expert Comment

by:adomsg
ID: 9872395
the point given by NetPointer is for file upload...that is upload the file to server..
U also need to add this encType="multipart/form-data" under ur <form> tab in the html.
0
 
LVL 5

Expert Comment

by:arvindb1
ID: 9872582
and for downloading from server to client , to open dialog you can do something like this


                        Response.Clear()
                        Response.ContentType = "application/octet-stream"
                        Response.AddHeader("Content-Disposition", _
                          "attachment; filename=""" & filename & """")
                        Response.Flush()
                        Response.WriteFile(filepath)

Arvind
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:tgatif
ID: 9885662
I want the file browser dialog in Web Application which is equivalent to file browser dialog in Windows Application.
0
 

Accepted Solution

by:
Priya25 earned 1000 total points
ID: 9902403
Sub DisplayDownloadDialog(ByVal PathVirtual As String)
        Dim strPhysicalPath
        Dim objFileInfo As System.IO.FileInfo
        Dim strFileName As String = "C:\Inetpub\wwwroot\Mercator\" + FileNameCSV
        Try
            strPhysicalPath = Server.MapPath(FileNameCSV)
            'exit if file does not exist
            If Not System.IO.File.Exists(strPhysicalPath) _
                 Then Exit Sub
            objFileInfo = New System.IO.FileInfo(strPhysicalPath)
            Response.Clear()
            'Add Headers to enable dialog display
            Response.AddHeader("Content-Disposition", "attachment; filename=" & _
                objFileInfo.Name)
            Response.AddHeader("Content-Length", objFileInfo.Length.ToString())
            Response.ContentType = "application/octet-stream"
            Response.WriteFile(objFileInfo.FullName)
        Catch
        Finally
            Response.End()
        End Try
    End Sub


Call the above procedure and give the full path name of the file to be saved when calling it as shown below and make sure the path given exists on your machine. In my example I have a folder Billing in C:\Inetpub\wwwroot\Mercator


Dim FileNameCSV As String = "C:\Inetpub\wwwroot\Mercator\Billing\Billing-" &  ".csv"
DisplayDownloadDialog(FileNameCSV)

This should be working.
0
 

Expert Comment

by:sheeladonald
ID: 10712709
how do i open a save dialog box with filters as (*,jpeg, *.csv) in asp.net
0
 

Expert Comment

by:DavidTanis
ID: 13790090
After I click save, a blank page displayed. How do I get rid of it?  
0

Featured Post

Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The object model of .Net can be overwhelming at times – so overwhelming that quite trivial tasks often take hours of research. In this case, the task at hand was to populate the datagrid from SQL Server database in Visual Studio 2008 Windows applica…
In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question