Quick example:
<asp:ScriptManager runat="server" EnablePageMethods="true" />
<!-- or ToolkitScriptManager, but remember to put only one -->
<script type="text/javascript">
function invokeMethod() {
x = document.getElementById('<%= TextBox1.ClientID %>').value;
PageMethods.theMethod(x, OnSuccess, OnFailure);
}
function OnSuccess(r) {
document.getElementById('<%= TextBox1.ClientID %>').value = r;
}
function OnFailure(r) {
alert(r._message);
}
</script>
[System.Web.Services.WebMethod()]
public static string theMethod(string x)
{
return x + "!!!";
}
solved How to get control values and modify them in Page Methods?