Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 6th, 2012  |  syntax: None  |  size: 0.72 KB  |  hits: 26  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to use ajax to access code behind method with parameters
  2. public void lnkTag_Click(object sender, EventArgs e){
  3.         ...
  4.     }
  5.        
  6. public void lnkTag_Click(string linkText){
  7.         ...
  8.     }
  9.        
  10. $('myLinkButton').click(function() {
  11.       $.ajax...
  12.   })
  13.        
  14. $('myLinkButton').click(function() {
  15.     $.ajax({
  16.         type: "POST",
  17.         contentType: "application/json; charset=utf-8",
  18.         url: "yourpage.aspx/lnkTag_Click",
  19.         data: "{'linkText': '" + linkTextValue + "'}",
  20.         dataType: "json",
  21.         success: function(data) {
  22.             //do something if it's successful
  23.         },
  24.         error: function(jqXHR, textStatus, errorThrown) {
  25.             //do something if there's an error
  26.         }
  27.     });
  28. });