View Full Version : [FIXED] [V0.6] NumberField and AjaxEvents

Sep 10, 2008, 11:01 AM

The example below demonstrates that the NumberField is not being set on AjaxEvents ComboBox change event.

<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<script runat="server">
protected void drpBox_Change(object sender, AjaxEventArgs e)
txtName.Text = "Timothy";
txtPrice.Number = 1;
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
<ext:ScriptManager ID="ScriptManager2" runat="server" Theme="Gray" />
<ext:TabPanel ID="TabPanel" runat="server" ActiveTabIndex="0" AutoPostBack="True" AutoHeight="True" DeferredRender="True">
<ext:Tab ID="Tab1" runat="server" Title="Tab1">
<ext:ComboBox ID="drpBox" runat="server">
<ext:ListItem Text="1" />
<ext:ListItem Text="2" />
<Change OnEvent="drpBox_Change" />
<ext:TextField ID="txtName" runat="server" />
<ext:NumberField ID="txtPrice" runat="server" AllowDecimals="True" DecimalPrecision="2" />


Sep 10, 2008, 12:07 PM
Hi Timothy,

the fix in SVN

Sep 10, 2008, 12:10 PM
Thanks vlad!


Sep 10, 2008, 4:41 PM

Ext:HiddenField is the same.


Sep 10, 2008, 5:03 PM
Also the same for Ext:Store ... if I bind the data doesn't change.

Sep 10, 2008, 6:35 PM
I cleaned up some of the code re: how the Form Fields set their value during an AjaxEvent. The <ext:HiddenField> should be working properly now. The same problem existed in <ext:DateField> and <ext:DatePicker>.

The cause of the defect is that a small snippit of JavaScript must be dynamically created during the AjaxEvent and returned to be executed on the client. By default when you set a property during the Ajax event, the snippit returned will just try to set the property value in JavaScript. For example, by default, if you set the .Text property of the <ext:TextField> to "testing", the snippit returned will be "this.TextField1.text = \"testing\"". Unfortunately that snippit of JavaScript will not actually update the <input> field and the TextField will appear to not change.

Updating some properties with the client widget requires a function to be called on the client. To change the .Text property of the <ext:TextField> on the client, you must call the .SetValue() function.

We've created a mechanism within the controls to enable a custom Method or custom snippit to be returned by setting the [AjaxEventUpdate] Attribute. For example, the .Text property of the <ext:TextField> requires the .SetValue() Method to be called, so the [AjaxEventUpdate(MethodName="SetValue")] is added to the .Text property.

The AjaxEventUpdate Attribute above instructs the serializer to call the .SetValue() Method when the .Text property is set during an AjaxEvent.

Other options for the AjaxEventUpdateAttribute include:

[AjaxEventUpdate(MethodName = "SetTitle")] // Call a Method
[AjaxEventUpdate(Script = "this.{0}.setTitle({1});")] // Supply a custom script Template. Two values passed, 1. .ClientID &amp; 2. the Json Serialized property value.
[AjaxEventUpdate] // AutoGenerate, returns a property setter
Properties that do not update properly on the respose from an AjaxEvent do not have the proper [AjaxEventUpdate] attribute applied.

We made an initial pass through the Toolkit setting many of the required [AjaxEventUpdate] attributes, but there's still many that require hand modification.

If you find a property that does not update on the client after the AjaxEvent response, please let us know. Revising the [AjaxEventUpdate] Attribute will almost always be the solution.

Sep 10, 2008, 6:40 PM
Timothy (9/10/2008)Also the same for Ext:Store ... if I bind the data doesn't change.

Can you create a new thread for this bug report? I'm marking the original request as [FIXED].

Sep 10, 2008, 6:59 PM
Great thanks Geoffrey.

Will do.