Click here to Skip to main content
15,890,350 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I want to call jquery function from classlibrary file C#?

What I have tried:

function productDetails(product) {

alert("i am the function inside client template");

}
Posted
Updated 24-Jun-16 4:02am

1 solution

You never call any JavaScript functions from server side, because JavaScript works on the client side, with the help of jQuery or not. This is not how Web works. Server-side code only handles HTTP request and creates HTTP response, which can be any content, including HTML with JavaScript, JavaScript along, anything at all. And you can control what JavaScript does just be generating different scripts, depending on your server-side computation. It can be done by direct writing whole code in HTTP response, or via using ASP.NET syntax on a fragment of JavaScript code.

See also this class which facilitates client-side script control: ClientScriptManager Class (System.Web.UI).

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900