PDA

View Full Version : [FIXED] [V0.7] Bug with resolving controls



Timothy
Dec 03, 2008, 10:53 AM
Hello,

I hope this example and replication is clear enough; let me know if you need any further information.

The problem has to do with 2 controls using the same ID through user controls.

Example.aspx:


<%@ Page Language="C#" %>
<%@ Register Src="~/Example/Example.ascx" TagName="Grid" TagPrefix="Example" %>
<%@ 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">

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Example Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="True" />
<ext:ScriptManager runat="server" StateProvider="PostBack" />

<ext:TabPanel ID="TabPanel1" runat="server" AutoPostBack="True" DeferredRender="True">
<Tabs>
<ext:Tab runat="server" Title="Tab 1">
<Body>
<ExtJS:Button ID="btnSave" runat="server" AutoPostBack="False" Text="Save" MinWidth="80" />
</Body>
</ext:Tab>
<ext:Tab runat="server" Title="Tab 2">
<Body>
<Example:Grid runat="server" />
</Body>
</ext:Tab>
</Tabs>
</ext:TabPanel>


</form>
</body>
</html>



Example.ascx:


<%@ Control Language="C#" ClassName="Example" %>
<%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
Store1.DataSource = new object[] {
new object[] { "Timothy", "Cool" }
};
Store1.DataBind();
}
</script>

<ext:Store ID="Store1"
runat="server"
AutoLoad="False">
<Reader>
<ext:ArrayReader>
<Fields>
<ext:RecordField Name="Customer" />
<ext:RecordField Name="Value" />
</Fields>
</ext:ArrayReader>
</Reader>
</ext:Store>
<ext:GridPanel ID="GridPanel1"
runat="server"
StoreID="Store1"
AutoHeight="True"
AutoWidth="True">
<Listeners>
<AfterEdit Handler="#{btnSave}.enable()" />
</Listeners>
<ColumnModel>
<Columns>
<ext:Column ColumnID="Customer" DataIndex="Customer" Header="Customer" />
<ext:Column ColumnID="Value" DataIndex="Value" Header="Value">
<Editor>
<ext:ComboBox runat="server"
Editable="True">
<Items>
<ext:ListItem Text="Word" Value="Word" />
<ext:ListItem Text="Word 2" Value="Word 2" />
<ext:ListItem Text="Word 3" Value="Word 3" />
</Items>
</ext:ComboBox>
</Editor>
</ext:Column>
</Columns>
</ColumnModel>
<SelectionModel>
<ext:RowSelectionModel runat="server" />
</SelectionModel>
<BottomBar>
<ExtJS:Toolbar runat="server">
<Items>
<ExtJS:ToolbarButton ID="btnSave" runat="server" AutoPostBack="False" Disabled="True" StandOut="True" Text="Save" MinWidth="80" />
</Items>
</ExtJS:Toolbar>
</BottomBar>
</ext:GridPanel>


Replication steps:

1. Load page
2. Click on "Tab 2"
3. Edit the value under column Value to "Word 2"
4. Notice JS error

Explanation; I've rigged the GridPanel to enable the btnSave on the bottom Toolbar AfterEdit but it appears to be trying to grab the btnSave from the other Tab. If you remove or rename the Button from the first Tab, this example works.

Thanks so much for your support.

Cheers,
Timothy

geoffrey.mcgill
Dec 03, 2008, 11:39 AM
Hi Timothy,

Thanks for the code sample. I've reproduced the js error and I'm now stepping through the .FindControl Method to figure out exactly where it's failing to find the local "btnSave" instance. 


hmmm... just thought of something...

Timothy
Dec 03, 2008, 11:43 AM
Thanks Geoffrey,

I also noticed some other inconsistencies with the TabPanel and switching between Tabs with embedded GridPanels. However, I'm hoping it has something to do with this bug report, if you need me to submit an example I can whip one up. Otherwise, I will just wait and confirm your findings.

Cheers,
Timothy

Timothy
Dec 03, 2008, 6:02 PM
Geoffrey,

Any luck with this one? I can start posting my other findings, but I think they are related, let me know if more examples might help or not.

Cheers,
Timothy

geoffrey.mcgill
Dec 03, 2008, 6:13 PM
We did find the problem, but had to remove the setters from the Listeners. The setters really shouldn't have been on the properties anyways.

The only scenario where removing the setter would affect anyones code is if you specifically create a new ComponentListener object and set the Listener property with the new object.

Example


<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
// BAD
// The following will no longer work with v0.7
ComponentListener click = new ComponentListener();
click.Handler = "alert('Clicked!');";
this.Button1.Listeners.Click = click;

// GOOD
// Please just set the .Hander property directly.
this.Button1.Listeners.Click.Handler = "alert('Clicked!');";
}
</script>

I'm just finishing up some testing and will be committing soon.

Timothy
Dec 04, 2008, 1:13 PM
Confirmed, thanks.

Cheers,
Timothy