We help IT Professionals succeed at work.

Common Dialog.

rtcomp
rtcomp asked
on
Medium Priority
491 Views
Last Modified: 2008-03-06
How do I get a common Open File dialog to open in ASP or VBSCRIPT?
Comment
Watch Question

Commented:
<input type=file>

Beyond, what's the background and goal of your question?

Author

Commented:
I'm creating a sample fourm. In this application is a setting module that lest the Administrator choose different settings. One of the settings is the background image. I need the Common Open File Dialog (lthe one that oepn when you click on File then Open) so he/she can scoohe the file.

Commented:
So, you don't want to upload anything. - You can't access the <input type=file> text contents. There is a Java applet which extends the options (I'ld have to refind it, and it's not free). - Alternatively, you could use the MS Common Dialog control as ActiveX (IE only), for which I could give you the code.

Author

Commented:
I can try the MS Common Dialog control. Can you provide the code for that  and I'll see if that works? Thanks.
Commented:
Working sample:

-----------------------------------------------------------

<html>
<head>
     <script language="vbscript">
          Function GetCmnDlgValue()
               objCmnDlg.ShowOpen  
               MsgBox objCmnDlg.FileName
               document.form1.filename.value = objCmnDlg.FileName
          End Function
     </script>
</head>
<body>
     <object classid="CLSID:F9043C85-F6F2-101A-A3C9-08002B2F49FB"
      codebase="http://activex.microsoft.com/controls/vb6/COMDLG32.CAB"
     id="objCmnDlg"></object>
     
     <form name=form1>
     <input type=text name=filename>
     <input type="button" onclick="GetCmnDlgValue()" value="Get Value">
     </form>
</body>
</html>

-----------------------------------------------------------

Here's a good article on using that control client-side within HTML: http://www.siteexperts.com/tips/databinding/ts04/page3.asp
And here's the main documentation for the Common Dialog control (it's VB but you can easily adopt it for VBScript): http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cmdlg98/html/vbobjcommondialog.asp

If there are problems or questions, ask.

Author

Commented:
Bingo, thats exactly what I was loking for. Thanks
Hi,

This is also what I want to complete using VBscript:  Open File dialog to open in ASP or VBSCRIPT, and I read the articles listed above. I tried " Working sample" from " robbert ", but it doesn't work. The error: "Char: 16  Error: Object doesn't support this property or method: 'objCmnDlg.ShowOpen'  Code:0 ". Any ideas? Thanks.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.