Jul 20, 2009, 5:37 AM
Updating a window's content during an ajax callback (and showing)
I am using coolite 0.8
I have an ext:window control on one of my pages that is opened through an ajax event. The code behind that handles the ajax event changes some properties on a control that is inside the <Body> of the ext:window and then calls .show() on the ext.window... When the child control's properties change, the control ends up changing a Label during its prerender.
...
The problem is that the content inside the child control (a Label in this case) is not updating on return of the ajax callback.
If I change the Label to an ext:Label, then it updates on the first .show(), but if I close the ext:window and call .show() again, I get a JS error in the coolite.js (if I remove the ext:Label I can .show() / hide / .show() / hide ... all day without any errors).
So, my question is two part:
1. Does coolite have something similar to the Atlas UpdatePanel? For this simple example, the ext:Label solves the problem (minus the script error) ... but for any real control, coolite can't possibly have every control I might use (since some might even be custom).
2. Am I missing something obvious, or doing this the wrong way?
For reference, here is some code:
<U>Test.aspx</U>
<%@ Register src="TestCtrl.ascx" tagname="TestCtrl" tagprefix="uc1" %>
.
.
.
<ext:Button ID="ShowAjax1" runat="server" Text="ShowAjax1">
<AjaxEvents>
<Click OnEvent="OnShowAjax1"></Click>
</AjaxEvents>
</ext:Button><br />
<ext:Button ID="ShowAjax2" runat="server" Text="ShowAjax2">
<AjaxEvents>
<Click OnEvent="OnShowAjax2"></Click>
</AjaxEvents>
</ext:Button><br />
<ext:Window ID="Window1" runat="server" Icon="Application" Title="Some Title"
Modal="True" Showonload="False" Shadow="Frame" Resizable="False" ResizeHandles="none"
ConstrainHeader="True" Plain="False" ShadowOffset="8"
Width="750px" Centeronload="True" BodyBorder="False" HideBorders="True"
Draggable="False" AutoHeight="True" CloseAction="Close">
<Body>
<uc1:TestCtrl ID="Test1" runat="server" />
</Body>
</ext:Window>
<U>Test.aspx.cs</U>
...
protected void OnShowAjax1(object sender, AjaxEventArgs e)
{
Test1.SiteID = "Ajax1";
Test1.EditMode = true;
Window1.Show(ShowAjax1);
}
protected void OnShowAjax2(object sender, AjaxEventArgs e)
{
Test1.SiteID = "Ajax2";
Test1.EditMode = false;
Window1.Show(ShowAjax2);
}
...
<U>TestCtrl.ascx</U><%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label><br />
<%-- Uncomment the next line (and the match line in the .cs) for a JS error --%>
<%-- <ext:Label ID="Label2" runat="server"></ext:Label> --%>
<U>TestCtrl.ascx.cs</U>
public partial class TestCtrl : System.Web.UI.UserControl
{
public string SiteID { get; set; }
public bool EditMode { get; set; }
protected override void OnPreRender(EventArgs e)
{
if(EditMode)
{
Label1.Text = "Edit " + SiteID;
}
else
{
Label1.Text = "Add " + SiteID;
}
// Label2.Text = Label1.Text;
}
}