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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Running vbscript using C#

Status
Not open for further replies.

xtraterrestrial

Programmer
Sep 23, 2003
38
0
0
CA
Hi
I have some vbscript (a function) that I would like to call form the server side using C#. Can anyone let me know what method or how I can do this?

thanks in advance
 
since this is a client side function you can only call it client side. but the code that needs to call your function can be generated at runtime.

so you can simply write
Code:
Response.Write("<script language=vbscript> functionName() </code>");

this way, when the browser will render the zone of the page where this statement is written, it will execute your function. but make sure your function is declared in the head section of your page.

post back if you still need help.

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
What if I wanted to call that function on an event. I.e. I click on a server side .NET button. I tried adding it to the "onClick" event of the HTML tag but it doesn't recognize the function name.

Is it even possible to do this?
 
just like I told you before, you can do this by writing the following line in the button event:
Code:
Response.Write("<script language='VBScript'>functionName()</script>");

but be aware that this will mean a roundtrip to the server. to do this on client side only, use this in C# (probably in the Form_Load event)
Code:
serverButtonName.Attributes.Add("onClick", "functionName(); return false;");

--------------------------
"two wrongs don't make a right, but three lefts do" - the unknown sage
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top