Solved

Create a button to open a local directory

Posted on 2004-10-04
10
398 Views
Last Modified: 2012-08-14
Hi Guys, I want to create a button people can press that will open a standard network drive folder on their computer.  At the moment I'm achieving this using a HyperLink like:

<asp:HyperLink id="HyperLink1" runat="server" Visible="False" Target="_blank" NavigateUrl="file://I:\NewFolder\Projects\">Browse Projects Browse</asp:HyperLink>

Unfortuantly though this isn't too obvious, I need to create it more in a button.  I've tried server.transfer and response.redirect and even trying to open the folder in an <IFrame> but with no success.

Can anybody help?
0
Comment
Question by:Stamper
[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
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 12217293
You can try adding the following code to the button:

void Page_Load(object src, EventArgs e)
{
    myButton.Attributes.Add("OnClick","javascript:window.open(\"file://I:\NewFolder\Projects\\")");
}

Best, Nauman.
0
 
LVL 28

Expert Comment

by:mmarinov
ID: 12217317
Hi,

unfortunately you have no access on the user machine
with the example you've posted you open the folder on the server, not on the client

Regards,
B..M
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12217360
mmarinov is exactly right, you will not be able to expose a clients file listing in your app without the use of an activex control, etc.  This would be a varitable Pandora's box of security issues and for this reason your requested functionality is not possible without a client plugin

Aeros
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 12217572
If you just want to open the explorer window to open the folder then I think you can do it easily as this javascript is working perfectly fine:

<input type="button" value="Button" name="B3" onClick="javascript:window.open('file:///c:/')">

What exactly are you trying to do? Can you explain?

Thanks, Nauman.


0
 

Author Comment

by:Stamper
ID: 12218538
Every computer on the network has access to a network drive.  On clicking the button - I want a Windows Explorer folder to launch up so they can browse around that file.  I don't want access to it.  I just want them to be able to see it on their own computer.
0
 
LVL 17

Expert Comment

by:AerosSaga
ID: 12218571
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
   If Not IsPostBack Then
       Dim di As DirectoryInfo = New DirectoryInfo("c:\Events\HTML\Event\")
       Dim ds As DataSet = new DataSet()
       Dim fis as FileInfo()
       Dim fi as FileInfo()

       ds.Tables.Add()
       ds.Tables(0).Columns.Add("FileName")
       ds.Tables(0).Columns.Add("path")

       fis = di.GetFiles()
       For Each fi in fis
           Dim dr as DataRow = ds.Tables(0).NewRow()
           dr(0) = fi.Name
           dr(1) = "your web application virtual directory name" & fi.Name
           ds.Tables(0).Rows.Add (dr)
       Next

       ddlPages.DataSource = ds
       ddlPages.DataTextField = "FileName"
       ddlPages.DataValueField = "path"
       ddlPages.DataBind()

End Sub

Not sure if it will work with a mapped drive, but I think UNC shares are ok

Aeros
0
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 250 total points
ID: 12218632
Stamper,

Did you try using the code that I posted?

myButton.Attributes.Add("OnClick","javascript:window.open(\"file:///I:\NewFolder\Projects\\")");

-Nauman.
0
 

Author Comment

by:Stamper
ID: 12218756
yup nauman but it didnt work... but that code looks good and if i type the file:// into my run window then it pops up - which is what i want exactly.

So I think maybe the permisions could be set up wrong on my browser?
0
 
LVL 25

Expert Comment

by:nauman_ahmed
ID: 12218903
what error are you getting?

-nauman.
0
 

Author Comment

by:Stamper
ID: 12224967
nothings happening at all, the code looks fairly right and what I was after so I've accepted it.  I think I probobly need a good play around with my browser and its security settings
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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