| | |
Open file Dialog in asp.net
Please support our ASP.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Thread Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Solved Threads: 0
Hi all,
I want to have a button in a page like 'open File'. on which if user clicks, it should open open file dialog box to select a file and as soon as he clicks on the open button it should open the file (in same window or different window)
I tried using the "FileUpload 'Button but it comes in combination along textbox and button. but i need only button.
I tried <input id="file1" Type="File" runat="server"/> in html view this is also the same thing
can anybody help me such that on button click it should open file select dialog box on local machine(where the user is accessing )select file and open it.
i know how to do it in windows app but i need to do it in web app.
Thanks in advance
Naresh
I want to have a button in a page like 'open File'. on which if user clicks, it should open open file dialog box to select a file and as soon as he clicks on the open button it should open the file (in same window or different window)
I tried using the "FileUpload 'Button but it comes in combination along textbox and button. but i need only button.
I tried <input id="file1" Type="File" runat="server"/> in html view this is also the same thing
can anybody help me such that on button click it should open file select dialog box on local machine(where the user is accessing )select file and open it.
i know how to do it in windows app but i need to do it in web app.
Thanks in advance
Naresh
you cant hide the textbox but if you set the display style property of the FORM element to 'none' and create another element of type button then using javascript you can open the dialog onClick of the button e.g.
ASP.NET Syntax (Toggle Plain Text)
<form name="form1"/> <input type="file" name="filediag" style="display:none" /> <input type="button" value="browse..." onclick="document.form1.filediag.click()" /> </form>
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Solved Threads: 0
•
•
•
•
you cant hide the textbox but if you set the display style property of the FORM element to 'none' and create another element of type button then using javascript you can open the dialog onClick of the button e.g.
ASP.NET Syntax (Toggle Plain Text)
<form name="form1"/> <input type="file" name="filediag" style="display:none" /> <input type="button" value="browse..." onclick="document.form1.filediag.click()" /> </form>
I had already done it upto that extent(of which i am able to get path of the file into textbox(which is not visible)but with more number of lines)ok.
but now what my question is that
after opening the 'Choosefile'dialog onClick of button('browse')
and select one (ex:- *.xml) file ->click on 'Open' button on 'Choosefile'dialog .then
it should open that file in a new browser or some editor.
ok then just simply add an onchange event to your FILE input.
the above code will open the path of the file in a new browser window.
be aware this is only supported by I.E.6 + mozilla 1.5+ i believe as the onchange event in an INPUT of type file never used to work.
ASP.NET Syntax (Toggle Plain Text)
<form name="form1"/> <input type="file" name="filediag" style="display:none" onchange="window.open(this.value, '_blank')" /> <input type="button" value="browse..." onclick="document.form1.filediag.click()" /> </form>
be aware this is only supported by I.E.6 + mozilla 1.5+ i believe as the onchange event in an INPUT of type file never used to work.
When Autumn Falls [ http://www.whenautumnfalls.co.uk ] &&
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
Designdotworks [ http://www.designdotworks.co.uk ] Web / Graphic / Software Design
![]() |
Similar Threads
- Difference between asp & asp.net (ASP.NET)
- Can't Open Web Pages where ASP.net (Web Browsers)
- file open dialog box control in asp.net (ASP.NET)
- Is it possible to execute the ASP.NET code in command prompt..? (C#)
- Batch file in ASP.Net to convert Excel files into higher version (ASP.NET)
- Simple ASP.Net Login Page (Using VB.Net) (ASP.NET)
- C#ASP.Net: how to browse the folder list on Server? (C#)
- ASP.NET problem (ASP.NET)
- Populating & Retrieving Data in a listbox : ASP.NET (w/ VB.NET) (ASP.NET)
Other Threads in the ASP.NET Forum
- Previous Thread: Help with ArrayList as returned argument
- Next Thread: Load Report Failed
| Thread Tools | Search this Thread |
.net 2.0 3.5 activexcontrol advice ajax alltypeofvideos asp asp.net bc30451 bottomasp.net browser businesslogiclayer c# c#gridviewcolumn checkbox class commonfunctions compatible confirmationcodegeneration content contenttype countryselector courier css dataaccesslayer database datagrid datagridview datagridviewcheckbox datalist development dgv dropdownlist dropdownmenu dynamic dynamically edit fileuploader fill findcontrol flash flv formatdecimal forms formview gridview gudi homeedition iframe iis javascript jquery listbox menu microsoft mouse mssql multistepregistration nameisnotdeclared news objects opera panelmasterpagebuttoncontrols problem redirect registration relationaldatabases reportemail rotatepage schoolproject security serializesmo.table silverlight smartcard smoobjects software sql sql-server sqlserver2005 ssl textbox tracking unauthorized validation vb.net video videos virtualdirectory vista visual-studio visualstudio web webapplications webarchitecture webdevelopemnt webdevelopment webprogramming webservice youareanotmemberofthedebuggerusers





