Link to home
Start Free TrialLog in
Avatar of jskfan
jskfanFlag for Cyprus

asked on

open dialogbox in ASP.NET

I am using this code below so that i can open a dialog box and select a folder from a drive, and make the folder name and path show up on the text box in the web form, but it doesn't open the dialog box.

Any idea?

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        Me.Button6.Attributes.Add("OnClick", "ShowDialog();")
    End Sub

thanks
Avatar of Ivo Stoykov
Ivo Stoykov
Flag of Bulgaria image

Hello jskfan,

>   Me.Button6.Attributes.Add("OnClick", "ShowDialog();")
move this into Form_PreRender event

HTH

I
Avatar of jskfan

ASKER

<<<<<<<<<Me.Button6.Attributes.Add("OnClick", "ShowDialog();")
move this into Form_PreRender event>>>>>>>>>>>>.



it still doesn't do anything

Avatar of Pratima
try this in page_load.....................

May i see the code in ShowDialog() ?
SOLUTION
Avatar of Sammy
Sammy
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

the goal is to open a dialog  box and select a folder name in the network drive
Hi jskfan,

you cannot open a network drive with a browser unless it is mapped. This is a security issue.

regards

I
Hi jskfan,

Here is a sample of open folder dialog but you have to set permissions accordingly.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
<SCRIPT LANGUAGE="JavaScript">
<!--
function t()
{
  var WINDOW_HANDLE = 0;
  var OPTIONS = 0;

  var objShell = new ActiveXObject("Shell.Application");
  var objFolder = objShell.BrowseForFolder(WINDOW_HANDLE, "Select a folder:", OPTIONS, "C:\\");

  if(objFolder== null)  {    Wscript.Quit() ; }

  var objFolderItem = objFolder;
  var objPath = objFolderItem.Path;

  document.write(objPath);
}  // end function

//-->
</SCRIPT>
</HEAD>

<BODY onclick="t();">
Click me
</BODY>
</HTML>


regards

I
Avatar of jskfan

ASKER

ivostoykov ,

where do you want me to paste this HTML code above?
I need a click button that browse through the drive folders
Hi jskfan,

sorry for the delay but i was out for a wahile...

1. Add script as a standard script block into the header
2. attach finction to desired object, i.e.
Me.Button6.Attributes.Add("OnClick", "t();")

regards

I
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jskfan

ASKER

Sorry, I am using ASP.NET and could not get your code to work
Hi jskfan,
The code is indeed for asp.net

The button3_click subroutine executes and displays the cotents of open file dialog in a textbox .

I am using this code in an ecommerce ASP.NET web application. And it's working.
Avatar of jskfan

ASKER

skvikram ,

that was excellent!!!

1-I didn't know that you can  put sub procedure in the HTML page, I did and it run just good.

2-Can the open dialog box pickup a folder instead of a file? if it is not incovenient for you can you show me how to do it?

Thanks a lot!!!!
Avatar of jskfan

ASKER

In other words, can you please take a little bit more of pain to explain your code?
 thanks
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial