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

How to call JavaScript function in C# code?

Status
Not open for further replies.

jgraves13

Programmer
Jan 31, 2007
42
US
Hello,

I have this JavaScript file on a server that I would like to make a call to a specific function in the JavaScript, how can this be done?
 
I dont' think c# and js can communicate directly. no different than c# and java, or c# and php could communicate.

why not reproduce the js functionality within the c# language?

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
I'm assuming this is an ASP.NET question. You can invoke or inject a .js file into your ASP.NET code. I'm not sure if this is available pre-.NET 2.0.

Code:
ClientScript.RegisterClientScriptInclude("YourScript","YourJSFile.js")
This injects a script tag with the following attributes into the rendered html.
Code:
<script src="YourJSFile.js" type="text/javascript"></script>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top