
Untitled
By: a guest on
Aug 6th, 2012 | syntax:
None | size: 0.72 KB | hits: 26 | expires: Never
How to use ajax to access code behind method with parameters
public void lnkTag_Click(object sender, EventArgs e){
...
}
public void lnkTag_Click(string linkText){
...
}
$('myLinkButton').click(function() {
$.ajax...
})
$('myLinkButton').click(function() {
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "yourpage.aspx/lnkTag_Click",
data: "{'linkText': '" + linkTextValue + "'}",
dataType: "json",
success: function(data) {
//do something if it's successful
},
error: function(jqXHR, textStatus, errorThrown) {
//do something if there's an error
}
});
});