jquery in asp.net+server side execution
-
Hi how to execute server side code in asp.net while using jquery. like some login form is opened by using jquery as model popup and how will be executed submit button click event. or any other way while using jquery to perform login form functionality. thanks
You get the best out of others when you give the best of yourself.
-
Hi how to execute server side code in asp.net while using jquery. like some login form is opened by using jquery as model popup and how will be executed submit button click event. or any other way while using jquery to perform login form functionality. thanks
You get the best out of others when you give the best of yourself.
trilokharry wrote:
execute server side code in asp.net while using jquery
The most common method I use for this purpose is WebMethod. 1. Create a webmethod in your code behind.
[System.Web.Services.WebMethod(EnableSession = true)]
public static string DemoMethodInCodeBehind(string msg)
{
return "OK_" + msg;
}2. Write a javascript function to call this web method.
function demo()
{
PageMethods.DemoMethodInCodeBehind('hello',OnGetMessageSuccess, OnGetMessageFailure);
}3. Implement success & failure methods in java script.
function OnGetMessageSuccess(result, userContext, methodName)
{
alert("Success " + result);
}function OnGetMessageFailure(error, userContext, methodName)
{
alert("Failed");
}4. Now call Demo on button click.
-
Hi how to execute server side code in asp.net while using jquery. like some login form is opened by using jquery as model popup and how will be executed submit button click event. or any other way while using jquery to perform login form functionality. thanks
You get the best out of others when you give the best of yourself.
trilokharry wrote:
like some login form is opened by using jquery as model popup and how will be executed submit button click event.
The jQuery model popup displays the content of the DIV itself. I you use asp buttons inside your div to complete the login process you should have no problem accessing their _OnClick method in code behind.
-
trilokharry wrote:
like some login form is opened by using jquery as model popup and how will be executed submit button click event.
The jQuery model popup displays the content of the DIV itself. I you use asp buttons inside your div to complete the login process you should have no problem accessing their _OnClick method in code behind.
button click event not getting executed. thanks for your kind reply.
You get the best out of others when you give the best of yourself.
-
button click event not getting executed. thanks for your kind reply.
You get the best out of others when you give the best of yourself.
In that case you can go for page methods.
-
trilokharry wrote:
execute server side code in asp.net while using jquery
The most common method I use for this purpose is WebMethod. 1. Create a webmethod in your code behind.
[System.Web.Services.WebMethod(EnableSession = true)]
public static string DemoMethodInCodeBehind(string msg)
{
return "OK_" + msg;
}2. Write a javascript function to call this web method.
function demo()
{
PageMethods.DemoMethodInCodeBehind('hello',OnGetMessageSuccess, OnGetMessageFailure);
}3. Implement success & failure methods in java script.
function OnGetMessageSuccess(result, userContext, methodName)
{
alert("Success " + result);
}function OnGetMessageFailure(error, userContext, methodName)
{
alert("Failed");
}4. Now call Demo on button click.
not getting exactly what to do with this code. I tried but no output. I'm new in jquery so please help me.
You get the best out of others when you give the best of yourself.
-
not getting exactly what to do with this code. I tried but no output. I'm new in jquery so please help me.
You get the best out of others when you give the best of yourself.
Calling server side code does not have anything to do with jQuery. It can be achieve easily using javascript. http://www.dev102.com/2008/04/30/call-aspnet-webmethod-from-jquery/[^] http://www.xdevsoftware.com/blog/post/Call-WebMethod-from-Javascript-in-ASPNET.aspx[^]