Solved

Open File Dialog in ASP.net c#

Posted on 2008-06-23
4
4,260 Views
Last Modified: 2008-07-01
Hi,

 I need that any user can click on a button and an open file dialog is displayed showing only files from web solution 'images' repository so I get the name of a file found in that folder

Thanks in advance
0
Comment
Question by:negreteo
[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
  • 2
  • 2
4 Comments
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21850894
ASP.Net has to talk through http and the web browser, just like any other web site.  And web site can't open the common open file dialog for the server's file system.  Period.
0
 

Author Comment

by:negreteo
ID: 21851634
what about using a javascript?
0
 
LVL 18

Expert Comment

by:jcoehoorn
ID: 21851885
The only thing you can do is include a an <input type="file" /> tag.  You will have to implement your own page to show the file listing.
0
 

Accepted Solution

by:
negreteo earned 0 total points
ID: 21852006
This code does the works!!!

const string fiName = "fileBrowse";
System.Text.StringBuilder sb = new System.Text.StringBuilder();

sb.Append("<div style='visibility: hidden; width: 0px; height: 0px'>");
sb.Append(string.Format("<input type=file id='{0}' accept='image/gif,image/jpeg'></div>", fiName));
sb.Append("<Script language=JavaScript> function BrowseClick(){");
sb.Append(String.Format("document.forms[0]['{0}'].click();", fiName));
sb.Append(String.Format("document.forms[0]['{0}'].value = document.forms[0]['{1}'].value;", txtIcon.ClientID, fiName));
sb.Append("return false;} </Script>");
 

RegisterClientScriptBlock("scriptKey", sb.ToString());
cmdGo.Attributes.Add("OnClick", "return BrowseClick();");      
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…

687 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