.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

how to call a C# function from a javascript function

Posted By: jay     Posted Date: May 13, 2010    Points:2   Category :C#
i have a javascript function. how to call a C# function from a javascript function

<script type="text/javascript">
function jsfun()


AND my C# function
protected void csharpfun(object sender, ImageClickEventArgs e)

Now i want to call csharpfun() from jsfun()

Author: Lalij Mer             
Posted Date: May 14, 2010     Points: 5   
Author: Venkat             
Posted Date: May 14, 2010     Points: 5   


Make you C# method public and with native parameter like int, string etc so that you can pass the argument from Javascript.

In the above C# method you have ImageClickEventArgs which is not available in Javascript scope so your C# method you can not call.

Now to call C# method using javascript you can do like this

<script type="text/javascript">
function jsfun()
var temp = <%=YourCSharpMethod()%>;


Mark As Answer if this solve your problem
Warm Regards,

Post Reply

You must Sign In To post reply
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend