PDA

View Full Version : [ADDED] [V0.6] HiddenField AjaxEvents and Listeners



Timothy
Sep 11, 2008, 12:18 PM
Hello,

Would it be possible to get AjaxEvents added to the Ext:Hidden field so that an event can be fired when the value changes on the client-side ?

Would be proper cool!

Cheers,
Timothy

geoffrey.mcgill
Sep 11, 2008, 8:43 PM
Quick update: I have the <Change> Listener and AjaxEvent working, just need to do some more testing and will commit to svn tomorrow. 

geoffrey.mcgill
Sep 12, 2008, 8:02 PM
Hi Timothy,

The <Change> Listener and AjaxEvent has been added to the <ext:Hidden> Field control.

The following sample demonstrates using a <Click> Listener on an <ext:Button> to set the value of a <ext:Hidden> field, which then automatically fires a <Change> AjaxEvent. Within the Hidden1_Change event on the server I set the .Text property of an <ext:Label>.

Example


<%@ Page Language="C#" %>

<%@ Register assembly="Coolite.Ext.Web" namespace="Coolite.Ext.Web" tagprefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">
protected void Hidden1_Change(object sender, AjaxEventArgs e)
{
this.Label1.Text = "The HiddenField was updated: " + this.Hidden1.Value.ToString();
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<p><a href="AjaxEvent.aspx">Reload</a></p>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />

<ext:Hidden ID="Hidden1" runat="server">
<AjaxEvents>
<Change OnEvent="Hidden1_Change" />
</AjaxEvents>
</ext:Hidden>

<ext:Button
ID="Button1"
runat="server"
Text="Submit"
AutoPostBack="false">
<Listeners>
<Click Handler="#{Hidden1}.setValue('Testing...');" />
</Listeners>
</ext:Button>

<ext:Label ID="Label1" runat="server" />
</form>
</body>
</html>

Thanks for pointing out this functionality was missing.

Hope this helps.