1、AjaxEvet:
//这是一个服务端方法
protected void UpdateTimeStamp(object sender, AjaxEventArgs e)
{
this.SetTime();
}
//Html 调用上述方法
<ext:Button ID="Button1" runat="server" Text="Click Me">
<AjaxEvents>
<Click OnEvent="UpdateTimeStamp">
<EventMask ShowMask="true" MinDelay="500" Msg="Updating TimeStamp..." />
</Click>
</AjaxEvents>
</ext:Button>
OnEvent="UpdateTimeStamp" 就是指点击按钮后调用服务端方法UpdateTimeStamp 来更新某个标签的时间
2、AjaxMethod:
<script runat="server">
[AjaxMethod]
public void SetTimeStamp()
{
this.Label1.Text = string.Concat("Server Time: ", DateTime.Now.ToLongTimeString());
}
</script>
<ext:Button ID="Button5" runat="server" Text="Click Me" Icon="Lightning">
<Listeners>
<Click Handler="Coolite.AjaxMethods.SetTimeStamp();" />
</Listeners>
</ext:Button>
3、Web.Config
第一次用coolite的人基本都会漏掉配置这一至关重要的环节。如果想开启ajax事件,请记得在web.config 里做以下配置:
<httpHandlers>
<add path="*/coolite.axd" verb="*" type="Coolite.Ext.Web.ResourceManager" validate="false"/>
</httpHandlers>
<httpModules>
<add name="AjaxRequestModule" type="Coolite.Ext.Web.AjaxRequestModule, Coolite.Ext.Web"/>
</httpModules>
<modules>
<!--Coolite Config-->
<add name="AjaxRequestModule" preCondition="managedHandler" type="Coolite.Ext.Web.AjaxRequestModule, Coolite.Ext.Web"/>
</modules>
<handlers>
<!--Coolite Config-->
<add name="AjaxRequestHandler" verb="*" path="*/coolite.axd" preCondition="integratedMode" type="Coolite.Ext.Web.ResourceManager"/>
</handlers>