I got some requests on how to use inline code with Ajax.NET. Here is a small demo that will get the server time:
<%@ Page language="c#" Inherits="System.Web.UI.Page" ClassName="WebForm6"%>
<script runat="server" language="C#">
private void Page_Load(object sender, System.EventArgs e) { // ASP.NET 1.x creates a new class for each ASPX file. By default // the classname is something like ASP.webform6_aspx, the filename // of the ASPX file. To change this you can add the ClassName // attribute to the Page directive (see first line).
AjaxPro.Utility.RegisterTypeForAjax(typeof(WebForm6)); }
[AjaxPro.AjaxMethod] public DateTime GetServerTime() { return DateTime.Now; }
</script> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <html> <head> <title>WebForm6</title> </head> <body> <form id="Form1" method="post" runat="server">
<a href="javascript:doServerTime();void(0);">GetServerTime()</a>
</form>
<script type="text/javascript"> function doServerTime() { ASP.WebForm6.GetServerTime( function(res){ alert(res.value); } ); } </script> </body> </html>