Created
January 5, 2014 02:44
-
-
Save appforest/8263634 to your computer and use it in GitHub Desktop.
PageMethods & Webmethods (JS & C#)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks to Enrico Ariel @ http://www.youtube.com/watch?v=Kp4jxrs6uuI | |
//The codebehind: | |
[WebMethod] | |
public static string GetValues(string value) | |
{ | |
value = value +" - Sent @ " + DateTime.UtcNow.ToLongTimeString(); | |
return value; | |
} | |
//The JS: | |
function getValues() { | |
var text1 = $("#TextBox1").val(); | |
PageMethods.GetValues(text1, getValues_success, getValues_err); | |
} | |
function getValues_success(response) { | |
alert(response); | |
} | |
function getValues_err(errorMsg) { | |
alert(errorMsg.get_message()); | |
} | |
//The ASP must include a ScriptManager like: | |
<asp:ScriptManager runat="server" ID="scriptManager1" EnablePageMethods="true"></asp:ScriptManager> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment