Merge pull request #1345 from mattleibow/websocket-continuation-frame-fix
[mono.git] / mcs / class / System.Web / Test / mainsoft / NunitWebResources / EventValidationTest2.aspx
1 <%@ Page Language="C#"  %>
2 <%@ Implements Interface="System.Web.UI.ICallbackEventHandler" %>
3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
4
5 <html xmlns="http://www.w3.org/1999/xhtml" >
6 <script runat="server" >
7     
8     string _eventName = "Fail";    
9     string _cbMessage = "";
10     // Define method that processes the callbacks on server.
11     public void RaiseCallbackEvent(String eventArgument)
12     {
13         try {
14             this.ClientScript.ValidateEvent (_eventName, this.ToString ());
15             _cbMessage = "Correct event raised callback.";
16         }
17         catch (Exception ex) {
18             _cbMessage = "Incorrect event raised callback.";
19         }
20     }
21
22     // Define method that returns callback result.
23     public string GetCallbackResult()
24     {
25         return _cbMessage;
26     }
27
28     protected void Page_Load(object sender, EventArgs e)
29     {
30         if (!IsPostBack)
31         {
32             ClientScriptManager cs = Page.ClientScript;
33             String cbReference = cs.GetCallbackEventReference ("'" +
34                 Page.UniqueID + "'", "arg", "ReceiveServerData", "",
35                 "ProcessCallBackError", false);
36             String callbackScript = "function CallTheServer(arg, context) {" +
37                 cbReference + "; }";
38             cs.RegisterClientScriptBlock (this.GetType (), "CallTheServer",
39                 callbackScript, true);
40         }
41     }
42     
43     
44     protected override void Render(HtmlTextWriter writer)
45     {
46         this.ClientScript.RegisterForEventValidation("Test", this.ToString());
47         base.Render(writer);
48     }
49
50 </script>
51
52 <script type="text/javascript">
53 var value1 = new Date();
54 function ReceiveServerData(arg, context)
55 {
56     Message.innerText = arg;
57     Label1.innerText = "Callback completed at " + value1;
58     value1 = new Date();
59 }
60 function ProcessCallBackError(arg, context)
61 {
62     Message.innerText = 'An error has occurred.';
63 }
64 </script>
65
66 <html  >
67 <head id="Head1" runat="server">
68     <title>CallBack Event Validation Example</title>
69 </head>
70 <body>
71     <form id="Form1" runat="server">
72     <div>
73       Callback result: <span id="Message"></span>
74       <br /> <br />
75       <input type="button"
76              id="button1" 
77              runat="server"
78              value="ClientCallBack" 
79              onclick="CallTheServer(value1, null )"/>
80       <br /> <br />
81       <asp:Label id="Label1" runat="server"/>
82     </div>
83     </form>
84 </body>
85 </html>