Call ASP.NET Function From Javascript?

Total Post:128


 2027  View(s)
Rate this:

I'm writing a web page in ASP.NET. I have some Javascript, and I have a submit button with an onClick event.

Is it possible to call a method I created in ASP with Javascript's onClick event?
  1. Re: Call ASP.NET Function From Javascript?

    Hi Ashish,

    I suggest the Microsoft AJAX library. Once installed and referenced, you just add a line in your page load or init:


    Then you can do things like:

    <Ajax.AjaxMethod()> _

    Public Function Get5() AS Integer

        Return 5

    End Function

    Then, you can call it on your page as:


    The last parameter of your function call must be the javascript callback function that will be executed when the AJAX request is returned.


Please check, If you want to make this post sponsored

You are not a Sponsored Member. Click Here to Subscribe the Membership.