Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

open  dialogbox in ASP.NET

Posted on 2006-07-10
16
Medium Priority
?
1,788 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

636 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