Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Classic ASP and code behind

Status
Not open for further replies.

woter324

Technical User
Jan 26, 2007
179
GB
Hi,

I've written an HTA application for creating users in Active Directory that consists of .HTA, .HTM and .VBS files.

The next step for me is to make it a web based application. As 99% of the code is written in VBScript and saved in seperate files, the logical step is to use classic ASP. I am a newby to ASP and would like to know if it is possible to reference my vbs files from asp files?

If it is, I wonder if someone could be kind enough to provide a code snippit or example of how one might achieve this. I've looked at lots of classic ASP example, but they all seem to have inline code.

I've tried using:
Code:
<SCRIPT src="bin\test.vbs" language="VBScript"></script>

In my existing code, to call a function from a button, I'd use:
Code:
<input type="button" class="BTNPrintGP" id="BTNPrintGP"  tabIndex=19 onClick="doCmd('openPGPage')" value="Printer Groups..." />

So in the asp page, would I have to put the onClick event in asp tags? e.g.

Code:
<input type="button" class="BTNPrintGP" id="BTNPrintGP"  tabIndex=19 onClick="[b]<%[/b]doCmd('openPGPage')[b]%>[/b]" value="Printer Groups..." />


I'm all confused.com!!

If anyone can provide some help, I'd be very greatful.

Many thanks

Tex
 
mmmmm, you realize that VBscript only works in IE?

Try this:
Code:
<input type="button"  onClick="vbscript:doCmd('openPGPage')" value="Printer Groups..." />

(presuming doCmd is one of your vbscript functions)



 
as fox said, vbScript only works in IE...that being said:

doCmd can be either a "function" or "sub"

Code:
<script language="vbscript">
function doCmd(strInput)
	msgBox(strInput)
end function
</script>

<input type="button" onclick="doCmd('my text')" value="go" />


or you can give your "button" a name and use the native "onclick" vbscript for elements like this:

Code:
<script language="vbscript">
sub [b][COLOR=red]doCmd_onclick[/color][/b]
	msgBox("hello")
end sub
</script>

<input [b][COLOR=red]name="doCmd"[/color][/b] type="button" value="go" />


--------

GOOGLE is a great resource to find answers to questions like "how do i..."


--------
 
Thanks guys. On the train at the moment. I'll give 'em a go when I get home. Yes I know vbscript only works with IE, however, thanks to one inhouse application, we only support IE 6 so no problem there (yet).

Vicvirk, can the vb code be put into a seperate vbs file? It looks like it may be in an asp file with the html code in your example?

Yes docmd is a function in a vbs file.


Thanks again.
 
If you're working with ASP, you need to get it clear as to what happens on the server and what is sent to the client/browser.

Stuff inside the <% %> is processed by the server. The resultant string is sent to the client. A function call inside the <% %> will call the function from the server side and place the result in the "". It will not get activated by the client when the user clicks on the button.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top