?
Solved

open  dialogbox in ASP.NET

Posted on 2006-07-10
16
Medium Priority
?
1,786 Views
Last Modified: 2008-02-26
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
0
Comment
Question by:jskfan
[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
  • 6
  • 5
  • 3
  • +2
16 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17071113
Hello jskfan,

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

HTH

I
0
 

Author Comment

by:jskfan
ID: 17071184
<<<<<<<<<Me.Button6.Attributes.Add("OnClick", "ShowDialog();")
move this into Form_PreRender event>>>>>>>>>>>>.



it still doesn't do anything

0
 
LVL 39

Expert Comment

by:Pratima Pharande
ID: 17071269
try this in page_load.....................

May i see the code in ShowDialog() ?
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 27

Assisted Solution

by:Sammy Ageil
Sammy Ageil earned 400 total points
ID: 17071303
can you post the  ShowDialog() client code?
If I were to add this code in the page_load event of the webform Me.Button6.Attributes.Add("OnClick", "ShowDialog();")  and ShowDialog is a valid function, whatever script in the function will be executed

example

<script type="text/javascript">
function ShowAlert()
{
alert('Hello');
}
</script>

and in the page_load you add Me.Button6.Attributes.Add("OnClick", "ShowAlert();") the script will run fine.

one more thing you said >>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
are you trying to upload a file to the server? If yes then you can use <input id="uplTheFile" type=file runat="server"> in asp.net 1.1 or <asp:FileUpload ID="browse" runat="server" /> in asp.net 2.0

HTH
0
 
LVL 22

Assisted Solution

by:Ivo Stoykov
Ivo Stoykov earned 400 total points
ID: 17071450
Hi jskfan,

add also on page_load function

        Dim scriptString as String = "<script language=JavaScript> function ShowDialog() {"
        scriptString += "alert('Hi there'); }<"
        scriptString += "/"
        scriptString += "script>"
     
            If(Not IsClientScriptBlockRegistered("clientScript"))
        RegisterClientScriptBlock("dlg", scriptString)
        End If



regards

I
0
 

Author Comment

by:jskfan
ID: 17075296
the goal is to open a dialog  box and select a folder name in the network drive
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17088209
Hi jskfan,

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

regards

I
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17088239
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
0
 

Author Comment

by:jskfan
ID: 17109325
ivostoykov ,

where do you want me to paste this HTML code above?
I need a click button that browse through the drive folders
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17119890
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
0
 
LVL 7

Accepted Solution

by:
skvikram earned 1200 total points
ID: 17130361
<%@ Import Namespace="System.IO" %>
<Script runat="Server">
Sub Button3_Click(sender As Object, e As EventArgs)
Dim inFile as string
infile=inpFileUp.PostedFile.FileName
txtbox.Text = infile
End Sub
</Script>
<html><head></Head><body>
<form runat="server">
    <input id="inpFileUp"  tabIndex="7" size="20" Type="File" Runat="server" />
    <asp:TextBox id="txtBox" runat="server" />
    <asp:Button id="Button3" onclick="Button3_Click" Text="Save" runat="server"/>

</form>
</body></html>
0
 

Author Comment

by:jskfan
ID: 17161550
Sorry, I am using ASP.NET and could not get your code to work
0
 
LVL 7

Expert Comment

by:skvikram
ID: 17162220
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.
0
 

Author Comment

by:jskfan
ID: 17162861
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!!!!
0
 

Author Comment

by:jskfan
ID: 17162885
In other words, can you please take a little bit more of pain to explain your code?
 thanks
0
 
LVL 7

Assisted Solution

by:skvikram
skvikram earned 1200 total points
ID: 17163023
It is simple the button3_click subroutine takes the filename in infile variable and puts this in text box.

Dim inFile as string
infile=inpFileUp.PostedFile.FileName
Dim infolder as string
infolder=Path.GetDiretoryName(infile)
txtbox.Text = infolder


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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses

765 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