•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the ASP.NET section within the Web Development category of DaniWeb, a massive community of 456,234 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,754 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our ASP.NET advertiser: Lunarpages ASP Web Hosting
Views: 10037 | Replies: 5 | Solved
![]() |
•
•
Join Date: Nov 2007
Posts: 18
Reputation:
Rep Power: 2
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.
<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:
Rep Power: 2
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.
<form name="form1"/> <input type="file" name="filediag" style="display:none" /> <input type="button" value="browse..." onclick="document.form1.filediag.click()" /> </form>
thanks for giving it in minimum lines of script.
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.
<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
![]() |
•
•
•
•
•
•
•
•
DaniWeb ASP.NET Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
.net access ajax asp code combo custom data dell developer development dom drivers dropdownlist feed firefox graphics intel internet linux microsoft module mozilla msdn net news office open open source open-source opengl operating reader red hat reuse skin software source sql sun super system theme ubuntu vista weather web windows xml xoap
- 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


Linear Mode