Click here to Skip to main content
15,919,121 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: jquery in asp.net+server side execution Pin
saini arun11-Jun-10 20:21
saini arun11-Jun-10 20:21 
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.
GeneralRe: jquery in asp.net+server side execution Pin
trilokharry11-Jun-10 21:28
trilokharry11-Jun-10 21:28 
GeneralRe: jquery in asp.net+server side execution Pin
saini arun11-Jun-10 22:40
saini arun11-Jun-10 22:40 
AnswerRe: jquery in asp.net+server side execution Pin
saini arun11-Jun-10 20:24
saini arun11-Jun-10 20:24 
GeneralRe: jquery in asp.net+server side execution Pin
trilokharry11-Jun-10 20:58
trilokharry11-Jun-10 20:58 
GeneralRe: jquery in asp.net+server side execution Pin
saini arun11-Jun-10 21:11
saini arun11-Jun-10 21:11 
QuestionCrystal Reports in a web application [modified] Pin
Harshini8111-Jun-10 14:59
Harshini8111-Jun-10 14:59 
QuestionASP.NET and smooth colour changing Pin
Unsy11-Jun-10 10:45
Unsy11-Jun-10 10:45 
AnswerRe: ASP.NET and smooth colour changing Pin
thatraja11-Jun-10 19:40
professionalthatraja11-Jun-10 19:40 
AnswerRe: ASP.NET and smooth colour changing Pin
Amar Chaudhary12-Jun-10 17:26
Amar Chaudhary12-Jun-10 17:26 
Questiontrying to submit an httpwebrequest with hidden field and submit button data Pin
Member 391904911-Jun-10 10:25
Member 391904911-Jun-10 10:25 
QuestionRestrict logged in user to login again Pin
Hemant Thaker11-Jun-10 7:58
Hemant Thaker11-Jun-10 7:58 
AnswerRe: Restrict logged in user to login again Pin
Adam R Harris11-Jun-10 8:10
Adam R Harris11-Jun-10 8:10 
QuestionRe: Restrict logged in user to login again Pin
Hemant Thaker11-Jun-10 8:24
Hemant Thaker11-Jun-10 8:24 
AnswerRe: Restrict logged in user to login again Pin
Adam R Harris11-Jun-10 8:43
Adam R Harris11-Jun-10 8:43 
QuestionRe: Restrict logged in user to login again Pin
Hemant Thaker11-Jun-10 8:55
Hemant Thaker11-Jun-10 8:55 
AnswerRe: Restrict logged in user to login again Pin
Adam R Harris11-Jun-10 9:11
Adam R Harris11-Jun-10 9:11 
QuestionDinamically created gridview not handling SelectedIndexChanged Pin
Zasumo11-Jun-10 7:27
Zasumo11-Jun-10 7:27 
AnswerRe: Dinamically created gridview not handling SelectedIndexChanged Pin
Adam R Harris11-Jun-10 8:15
Adam R Harris11-Jun-10 8:15 
GeneralRe: Dinamically created gridview not handling SelectedIndexChanged Pin
Zasumo14-Jun-10 3:01
Zasumo14-Jun-10 3:01 
GeneralRe: Dinamically created gridview not handling SelectedIndexChanged Pin
Adam R Harris14-Jun-10 3:14
Adam R Harris14-Jun-10 3:14 
GeneralRe: Dinamically created gridview not handling SelectedIndexChanged Pin
Zasumo14-Jun-10 3:58
Zasumo14-Jun-10 3:58 
GeneralRe: Dinamically created gridview not handling SelectedIndexChanged Pin
Adam R Harris15-Jun-10 9:06
Adam R Harris15-Jun-10 9:06 
QuestionUsing Resource file in C# .NET Pin
VOITDOTNET11-Jun-10 7:10
VOITDOTNET11-Jun-10 7:10 
AnswerRe: Using Resource file in C# .NET Pin
Adam R Harris11-Jun-10 8:17
Adam R Harris11-Jun-10 8:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.