I have this question:
How could I call a codebehind method from jquery? I have a web page: (ForgetPass.aspx) with its respective codebehind (ForgetPass.aspx.cs). On the codebehind I have a public method:
public void ChangeSession(string strChangeSession)
{ some stuff... }
When I was working on MVC, calling that method was as simple as:
$.post("MyPageController/ChangeSession", { strChangeSession: 'yes' });
But now that I’m on aspx/C# I don’t know how to call that method from jquery (or maybe I need to use [WebMethod] clause on the codebehind ??)
Thanks in advance.
There’s a full run down here that explains the whole process 🙂
Yes you’ll need
[WebMethod]and it’ll need to be static as well, read the tutorial for an explanation on these bits.Based on your method names, you’ll probably need this: