PDA

View Full Version : [FIXED] [V0.7] Bug with adding script 'Ext.getDom(...' during ajaxevent



jchau
Dec 02, 2008, 11:14 PM
On button AjaxEvent click, I want to set the value of a hiddenfield on the page. I simply did the following:



Dim template As String = "Ext.getDom('{0}').value='{1}';"
Me.btnTest.AddScript(String.Format(template, "HiddenFieldClientID", "SomeValue"))


This threw a javascript error. The actual script set to the client has '<raw>' prepended plus the last 2 characters are swapped. Looks like TokenUtils.ParseTokens thinks my script is a function because it starts with 'Ext.get'. Not a big deal. I changed the script to something else that works. Just wanted to point this out in case someone is running into a similar issue.

geoffrey.mcgill
Dec 03, 2008, 9:00 AM
Hi Jacky,

Thanks for pointing this out. I'm running a few tests to reproduce and will provide a fix. 

geoffrey.mcgill
Dec 03, 2008, 9:24 AM
Hi Jacky,

Can you run the following sample and confirm if it's working for you or not.

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 Button1_Click(object sender, AjaxEventArgs e)
{
string tpl = "Ext.getDom('{0}').value='{1}';";
this.Button1.AddScript(tpl, this.HiddenField1.ClientID, "SomeValue");
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Coolite Toolkit Example</title>
</head>
<body>
<form id="form1" runat="server">
<ext:ScriptManager ID="ScriptManager1" runat="server" />

<ext:Button ID="Button1" runat="server" Text="Submit">
<AjaxEvents>
<Click OnEvent="Button1_Click" />
</AjaxEvents>
</ext:Button>

<asp:HiddenField ID="HiddenField1" runat="server" />
</form>
</body>
</html>

For me everything appears everything is working correctly, although maybe I'm missing something from your scenario.

jchau
Dec 03, 2008, 11:42 AM
Yup, I trimmed down the scenario too much. In my scenario, the AjaxEvent handler does more things that trigger more script to be sent to the client. The error occurs if Ext.getDom is not the only script that is being sent. I modified the AjaxEvent handler in your sample to also set the button's text.



protected void Button1_Click(object sender, AjaxEventArgs e)
{
this.Button1.SetText("New Text")
string tpl = "Ext.getDom('{0}').value='{1}';";
this.Button1.AddScript(tpl, this.HiddenField1.ClientID, "SomeValue");
}

geoffrey.mcgill
Dec 04, 2008, 8:56 AM
Hi Jacky,

The bug has been fixed and committed to SVN. 


Thanks for reporting the defect.