copied mono-api-diff.cs from mono-2-2 branch so new patch can be applied and history...
[mono.git] / mcs / class / System.Web / Test / mainsoft / NunitWebResources / EventValidationTest1.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 = "Test";    
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         public override string ToString () {
51                 return GetType ().Name;
52         }
53
54 </script>
55
56 <script type="text/javascript">
57 var value1 = new Date();
58 function ReceiveServerData(arg, context)
59 {
60     Message.innerText = arg;
61     Label1.innerText = "Callback completed at " + value1;
62     value1 = new Date();
63 }
64 function ProcessCallBackError(arg, context)
65 {
66     Message.innerText = 'An error has occurred.';
67 }
68 </script>
69
70 <html  >
71 <head id="Head1" runat="server">
72     <title>CallBack Event Validation Example</title>
73 </head>
74 <body>
75     <form id="Form1" runat="server">
76     <div>
77       Callback result: <span id="Message"></span>
78       <br /> <br />
79       <input type="button"
80              id="button1" 
81              runat="server"
82              value="ClientCallBack" 
83              onclick="CallTheServer(value1, null )"/>
84       <br /> <br />
85       <asp:Label id="Label1" runat="server"/>
86     </div>
87     </form>
88 </body>
89 </html>