473,989 Members | 39,410 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

File Selection Dialog

How do we invoke the file selection dialog? I would like to do this in C#
in ASP.net. I would like to open a file for reading.

Marathoner
Mar 9 '07 #1
13 7564
Hi,

OpenFileDialog ?

"marathoner " <ra******@msn.c om.invalidwrote in message
news:ed******** ******@TK2MSFTN GP02.phx.gbl...
How do we invoke the file selection dialog? I would like to do this in C#
in ASP.net. I would like to open a file for reading.

Marathoner

Mar 9 '07 #2
To use OpenFileDialog, I need to use the namespace "System.Windows .Forms".
It doesn't allow me to use this namespace in ASP.net. I get the following
error message:

error CS0234: The type or namespace name 'Windows' does not exist in the
namespace 'System' (are you missing an assembly reference?)

Marathoner

"Ignacio Machin ( .NET/ C# MVP )" <machin TA laceupsolutions .comwrote in
message news:u7******** ********@TK2MSF TNGP06.phx.gbl. ..
Hi,

OpenFileDialog ?

"marathoner " <ra******@msn.c om.invalidwrote in message
news:ed******** ******@TK2MSFTN GP02.phx.gbl...
>How do we invoke the file selection dialog? I would like to do this in
C# in ASP.net. I would like to open a file for reading.

Marathoner


Mar 9 '07 #3
marathoner wrote:
How do we invoke the file selection dialog? I would like to do this in C#
in ASP.net. I would like to open a file for reading.
Are you wanting the ability to select and then upload a file? If so, use
the FileUpload control. See
http://msdn2.microsoft.com/en-us/library/ms227669.aspx for more info on how
to use the control.
--
Tom Porterfield

Mar 9 '07 #4
I know how to upload a file. What I want to know is how to invoke a file
selection dialog box in ASP.net . I want to be able to select a file.

Marathoner

"Tom Porterfield" <tp******@mvps. orgwrote in message
news:ON******** ******@TK2MSFTN GP05.phx.gbl...
marathoner wrote:
>How do we invoke the file selection dialog? I would like to do this in
C#
in ASP.net. I would like to open a file for reading.

Are you wanting the ability to select and then upload a file? If so, use
the FileUpload control. See
http://msdn2.microsoft.com/en-us/library/ms227669.aspx for more info on
how to use the control.
--
Tom Porterfield

Mar 9 '07 #5
marathoner wrote:
I know how to upload a file. What I want to know is how to invoke a file
selection dialog box in ASP.net . I want to be able to select a file.
When you place the FileUpload control on a page it includes a Browse button
that allows for selection of a file. The FileUpload control doesn't
actually upload anything by itself, you have to add extra controls to the
ASP.net page to do the actual upload and save of the file. If you look at
the rendered HTML all it does is put an input element on the page of type
file:

<input type="file">

As I said, when the user clicks the browse button that is put of the file
input element, it will display the file selection dialog. See
http://www.quirksmode.org/dom/inputfile.html for some ideas on how you can
customize this type of input.
--
Tom Porterfield

Mar 9 '07 #6
With FileUpload, how do we retrieve the full pathname of the file selected?

Marathoner

"Tom Porterfield" <tp******@mvps. orgwrote in message
news:ei******** ******@TK2MSFTN GP02.phx.gbl...
marathoner wrote:
>I know how to upload a file. What I want to know is how to invoke a file
selection dialog box in ASP.net . I want to be able to select a file.

When you place the FileUpload control on a page it includes a Browse
button that allows for selection of a file. The FileUpload control
doesn't actually upload anything by itself, you have to add extra controls
to the ASP.net page to do the actual upload and save of the file. If you
look at the rendered HTML all it does is put an input element on the page
of type file:

<input type="file">

As I said, when the user clicks the browse button that is put of the file
input element, it will display the file selection dialog. See
http://www.quirksmode.org/dom/inputfile.html for some ideas on how you can
customize this type of input.
--
Tom Porterfield

Mar 9 '07 #7
On Fri, 9 Mar 2007 10:07:28 -0500, marathoner wrote:
How do we invoke the file selection dialog? I would like to do this in C#
in ASP.net. I would like to open a file for reading.

Marathoner
You need to very clear here. The file to be opened for reading is where
exactly? On the client or on the server?
--
Bits.Bytes
http://bytes.thinkersroom.com
Mar 10 '07 #8
jme
On Mar 9, 3:07 pm, "marathoner " <rajk2...@msn.c om.invalidwrote :
How do we invoke the file selection dialog? I would like to do this in C#
in ASP.net. I would like to open a file for reading.

Marathoner
The FileUpload Control is a fairly useless control for the task you
describe. Unfortunately when i tried to create a wrapper for the
OpenFileDialog (Made a DLL to call it) i got an error that
OpenFileDialog will only run if the Assembly is marked [STAThread] or
something similar. After playing around with this and not being able
to get it working i resorted to creating a custom form (I only wanted
to pick from one directory). It is obvious that the FileUpload calls
the OpenFileDialog but i suspect its internet explorer that calls it
and deals with the events. Does anyone know of a better control than
FileUpload?

Mar 12 '07 #9
It would be helpful if you could tell me how to do it either way (client or
server).

Thanks,

Marathoner
"Rad [Visual C# MVP]" <no****@nospam. comwrote in message
news:y1******** ******@thinkers room.com...
On Fri, 9 Mar 2007 10:07:28 -0500, marathoner wrote:
>How do we invoke the file selection dialog? I would like to do this in
C#
in ASP.net. I would like to open a file for reading.

Marathoner

You need to very clear here. The file to be opened for reading is where
exactly? On the client or on the server?
--
Bits.Bytes
http://bytes.thinkersroom.com

Mar 12 '07 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3431
by: GrantS | last post by:
I need urgent help. Done OK for a newbie getting automation of Windows Messenger into a Winform C# app but have three problems that I urgently need pointers to. Point 1 and 2 are the same issue, I think. Point 3 might relate to a threading issue: 1. I have written a C# Winform application that uses Windows messenger automation. When I attempt to send a file through the window messenger object, there is some horrid screen flicking...
3
4375
by: tungchau81 | last post by:
Hi, A Modal Dialog does not allow us to highlight the text content inside <DIV> tag unless I use a <textarea> tag to display that text content. However, the situation of my software makes it impossible to use <textarea> and Modeless dialog. I am really stuck!!! Is there any trick to make <DIV> or <SPAN>'s content be selectable in a Modal dialog? Thanks in advance,
2
2406
by: yanivoliver | last post by:
Hey, I'm currently trying to find a way to open a dialog box that will allow me to select more than one file at a time, so if I want to upload select all the files in a directory, I won't have to have the number of dialog boxes as files in the directory. I was thinking of using a ActiveX control, but I don't want to make the sure download additional components to be able to do this, so is there maybe some sort of Windows ActiveX control...
3
2315
by: JoNaS | last post by:
As a lot of us might now, the input file (aka browse button) in html does not allow for multiple file selection or for filtering file types. The File Open dialog used in WinForms allow these things and more. I developed a windows user control in VB.NET with a button and File Open Dialog, which allows multiple file selection. I registered the assembly with regasm.exe and call the object from the html page with the object tag: <OBJECT...
4
12069
by: MC D | last post by:
What's the best way to have a modal dialog that will only allow the selection of a FOLDER, rather than a file? Is there a property of the openFileDialog I'm missing, or is there another control altogether? I was thinking of doing it from a treeView, but It seems like there ought to be a control for this sort of thing! -D
2
4309
by: ahynes | last post by:
HI folks, I'm a chem engineer with no VB programming knowledge (as you'll see from my question!) I want a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this as a batch file or exe file which i can installt o run from my users desktops. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the...
2
19742
by: ahynes | last post by:
HI folks, I need a script to open a .txt file, insert pre-defined text into the start and end of the file, then close teh saved file with a .nc extension. I'd like to have this so I can run it from my desktop. I tried doing it in Word using macros and the FileDialog thingy to bring up dialogs for the user to select his files but it would not save the modified file for me and I couldn;t figure how to get it outside of Word. Code below.
5
2892
by: eddiefisher41 | last post by:
Hey Guys. This is kind of a mixed question involving the os platform, python and wxpython. I hope this is in the right place, if not then a quick link to somewhere suitable would be great. Ok basicly i have a dialog box that is acting as the GUI for an image program i'm running. The program is a front end support app for raw image files. Does anyone know how to invoke the dialog box if the user of the os clicks and tries to open a file of a...
8
3739
by: Janwillem | last post by:
Is there a way to force the wx.FileDialog to show as default the thumbnails vie in stead of list view? thanks, janwillem
0
10403
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10225
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11916
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10983
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
10152
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7691
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6494
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6657
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3831
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.