-<%@ Page Language="C#" %>\r
-<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>\r
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\r
-\r
-<html xmlns="http://www.w3.org/1999/xhtml" >\r
-<script runat="server" >\r
- \r
- string _eventName = "Test"; \r
- string _cbMessage = "";\r
- // Define method that processes the callbacks on server.\r
- public void RaiseCallbackEvent(String eventArgument)\r
- {\r
- try {\r
- this.ClientScript.ValidateEvent (_eventName, this.ToString ());\r
- _cbMessage = "Correct event raised callback.";\r
- }\r
- catch (Exception ex) {\r
- _cbMessage = "Incorrect event raised callback.";\r
- }\r
- }\r
-\r
- // Define method that returns callback result.\r
- public string GetCallbackResult()\r
- {\r
- return _cbMessage;\r
- }\r
-\r
- protected void Page_Load(object sender, EventArgs e)\r
- {\r
- if (!IsPostBack)\r
- {\r
- ClientScriptManager cs = Page.ClientScript;\r
- String cbReference = cs.GetCallbackEventReference ("'" +\r
- Page.UniqueID + "'", "arg", "ReceiveServerData", "",\r
- "ProcessCallBackError", false);\r
- String callbackScript = "function CallTheServer(arg, context) {" +\r
- cbReference + "; }";\r
- cs.RegisterClientScriptBlock (this.GetType (), "CallTheServer",\r
- callbackScript, true);\r
- }\r
- }\r
- \r
- \r
- protected override void Render(HtmlTextWriter writer)\r
- {\r
- this.ClientScript.RegisterForEventValidation("Test", this.ToString());\r
- base.Render(writer);\r
- }\r
-\r
- public override string ToString () {\r
- return GetType ().Name;\r
+<%@ Page Language="C#" %>
+<%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml" >
+<script runat="server" >
+
+ string _eventName = "Test";
+ string _cbMessage = "";
+ // Define method that processes the callbacks on server.
+ public void RaiseCallbackEvent(String eventArgument)
+ {
+ try {
+ this.ClientScript.ValidateEvent (_eventName, this.ToString ());
+ _cbMessage = "Correct event raised callback.";
+ }
+ catch (Exception ex) {
+ _cbMessage = "Incorrect event raised callback.";
+ }
+ }
+
+ // Define method that returns callback result.
+ public string GetCallbackResult()
+ {
+ return _cbMessage;
+ }
+
+ protected void Page_Load(object sender, EventArgs e)
+ {
+ if (!IsPostBack)
+ {
+ ClientScriptManager cs = Page.ClientScript;
+ String cbReference = cs.GetCallbackEventReference ("'" +
+ Page.UniqueID + "'", "arg", "ReceiveServerData", "",
+ "ProcessCallBackError", false);
+ String callbackScript = "function CallTheServer(arg, context) {" +
+ cbReference + "; }";
+ cs.RegisterClientScriptBlock (this.GetType (), "CallTheServer",
+ callbackScript, true);
+ }
+ }
+
+
+ protected override void Render(HtmlTextWriter writer)
+ {
+ this.ClientScript.RegisterForEventValidation("Test", this.ToString());
+ base.Render(writer);
+ }
+
+ public override string ToString () {
+ return GetType ().Name;
}
-\r
-</script>\r
-\r
-<script type="text/javascript">\r
-var value1 = new Date();\r
-function ReceiveServerData(arg, context)\r
-{\r
- Message.innerText = arg;\r
- Label1.innerText = "Callback completed at " + value1;\r
- value1 = new Date();\r
-}\r
-function ProcessCallBackError(arg, context)\r
-{\r
- Message.innerText = 'An error has occurred.';\r
-}\r
-</script>\r
-\r
-<html >\r
-<head id="Head1" runat="server">\r
- <title>CallBack Event Validation Example</title>\r
-</head>\r
-<body>\r
- <form id="Form1" runat="server">\r
- <div>\r
- Callback result: <span id="Message"></span>\r
- <br /> <br />\r
- <input type="button"\r
- id="button1" \r
- runat="server"\r
- value="ClientCallBack" \r
- onclick="CallTheServer(value1, null )"/>\r
- <br /> <br />\r
- <asp:Label id="Label1" runat="server"/>\r
- </div>\r
- </form>\r
-</body>\r
-</html>\r
+
+</script>
+
+<script type="text/javascript">
+var value1 = new Date();
+function ReceiveServerData(arg, context)
+{
+ Message.innerText = arg;
+ Label1.innerText = "Callback completed at " + value1;
+ value1 = new Date();
+}
+function ProcessCallBackError(arg, context)
+{
+ Message.innerText = 'An error has occurred.';
+}
+</script>
+
+<html >
+<head id="Head1" runat="server">
+ <title>CallBack Event Validation Example</title>
+</head>
+<body>
+ <form id="Form1" runat="server">
+ <div>
+ Callback result: <span id="Message"></span>
+ <br /> <br />
+ <input type="button"
+ id="button1"
+ runat="server"
+ value="ClientCallBack"
+ onclick="CallTheServer(value1, null )"/>
+ <br /> <br />
+ <asp:Label id="Label1" runat="server"/>
+ </div>
+ </form>
+</body>
+</html>