Design a Test.aspx page:
<asp:TextBox ID="Text1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Click" />
<br />
<div id="myDiv"></div>
Design Test.aspx.cs:
[WebMethod]
public static string ServerSideMethod(string paraml)
{
return "Message from Server" + paraml;
}
Design the client script:
$(document).ready(function () {
var name = 'stupid';
$('#<%=Button1.ClientID %>').click(function () {
$.ajax({
type: "POST",
url: "Default7.aspx/ServerSideMethod",
data: "{'paraml': " + $("#Text1").val() + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
async: true,
cache: false,
success: function (msg) {
$('#myDiv').text(msg.d);
}
})
return false;
});
});
Now execute the script.