473,383 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 7513
Hi,

OpenFileDialog ?

"marathoner" <ra******@msn.com.invalidwrote in message
news:ed**************@TK2MSFTNGP02.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****************@TK2MSFTNGP06.phx.gbl...
Hi,

OpenFileDialog ?

"marathoner" <ra******@msn.com.invalidwrote in message
news:ed**************@TK2MSFTNGP02.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**************@TK2MSFTNGP05.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**************@TK2MSFTNGP02.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.com.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**************@thinkersroom.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
marathoner wrote:
With FileUpload, how do we retrieve the full pathname of the file
selected?
Server side you access the .PostedFile.FileName property. Client side in
javascript you read the .value property.
--
Tom Porterfield

Mar 16 '07 #11
Hi

For opening dialog box and open file or whatever u want to do, u can do
with that.
Great thing is that u can also save textbox value(whic is selected from
dialog box)after page roundtrips.

Because if we select files from HTML input(Browse)
HTML Control then after page referesh or roundtrip that will be empty.

<input id="fileUploadInput" style="width: 57px" type="file"
runat="server" onpropertychange="txtInput.value = this.value" />
Server Control
txtInput(textbox)

So in HTML Code u can see i have set the value of input control to
"txtInput.value = this.value"

So now server control will maintain the state and that text box will not
empty after roundtrips of page.
So here we go.....

Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 16 '07 #12

Hi

For opening dialog box and open file or whatever u want to do, u can do
with that.
Great thing is that u can also save textbox value(whic is selected from
dialog box)after page roundtrips.

Because if we select files from HTML input(Browse)
HTML Control then after page referesh or roundtrip that will be empty.

<input id="fileUploadInput" style="width: 57px" type="file"
runat="server" onpropertychange="txtInput.value = this.value" />
Server Control
txtInput(textbox)

So in HTML Code u can see i have set the value of input control to
"txtInput.value = this.value"

So now server control will maintain the state and that text box will not
empty after roundtrips of page.
So here we go.....

Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 16 '07 #13


Hi

For opening dialog box and open file or whatever u want to do, u can do
with that.
Great thing is that u can also save textbox value(whic is selected from
dialog box)after page roundtrips.

Because if we select files from HTML input(Browse)
HTML Control then after page referesh or roundtrip that will be empty.

<input id="fileUploadInput" style="width: 57px" type="file"
runat="server" onpropertychange="txtInput.value = this.value" />
Server Control
txtInput(textbox)

So in HTML Code u can see i have set the value of input control to
"txtInput.value = this.value"

So now server control will maintain the state and that text box will not
empty after roundtrips of page.
So here we go.....

Nitin Sharma NXS

*** Sent via Developersdex http://www.developersdex.com ***
Mar 16 '07 #14

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

Similar topics

0
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...
3
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...
2
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...
3
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...
4
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...
2
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...
2
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...
5
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...
8
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
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.