Jul 22, 2009, 3:58 AM
[CLOSED] TaskManager in combination with ASP postback in a UpdatePanel
When combining a ext:TaskManger with another standard ASP postback within a UpdatePanel causes an error in an Ext component. At first we thought this was only in combination with a asp:Timer however it's also in combination with a asp:Button so I'm supposing it's always with an ASP postback
When the ASP postback fires, in Visual Studio 2008 you'll get an error "Microsoft JScript runtime error: Object doesn't support this property or method". The debuggers breaks on a line in the xhml file. When we Continue running the project the Ext controls have disappeared.
Note, that when you remove the asp:UpdatePanel, the script works again, only the TaskManager looses it's state (counter starts counting again from the position it was).
When the ASP postback fires, in Visual Studio 2008 you'll get an error "Microsoft JScript runtime error: Object doesn't support this property or method". The debuggers breaks on a line in the xhml file. When we Continue running the project the Ext controls have disappeared.
Note, that when you remove the asp:UpdatePanel, the script works again, only the TaskManager looses it's state (counter starts counting again from the position it was).
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="TestTool.Content.Test" %>
<%@ 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">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title>
</head>
<body>
<script runat="server">
protected void ruinScript_Tick( object sender , EventArgs e )
{
resultOfTheRuination.Text = "The Ext controls are on vacation now";
}
protected void manualRuination_Click( object sender , EventArgs e )
{
resultOfTheRuination.Text = "I sent the Ext controls on vacation, happy holidays!";
}
protected void countTask_Update( object sender , AjaxEventArgs e )
{
Int32 changes = Convert.ToInt32( hiddenCounter.Text );
changes++;
if ( changes == 1 )
{
resultLabel.Text = "First time change";
}
else if ( changes == 5 )
{
resultLabel.Text = "Last change (5)";
ScriptManager2.AddScript( "{0}.stopTask('countTask');" , TaskManager1.ClientID );
}
else
{
resultLabel.Text = string.Format( "I've been changed {0} times" , changes );
}
hiddenCounter.Text = changes.ToString( );
}
protected void stopCounting_Click( object sender , AjaxEventArgs e )
{
ScriptManager2.AddScript( "{0}.stopTask('countTask');" , TaskManager1.ClientID );
}
</script>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<ext:ScriptManager ID="ScriptManager2" runat="server">
</ext:ScriptManager>
<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<ext:TaskManager ID="TaskManager1" runat="server">
<Tasks>
<ext:Task TaskID="countTask" Interval="1000" AutoRun="true">
<AjaxEvents>
<Update OnEvent="countTask_Update" />
</AjaxEvents>
</ext:Task>
</Tasks>
</ext:TaskManager>
<ext:Hidden ID="hiddenCounter" runat="server" Text="0" />
<ext:Label ID="resultLabel" runat="server" Text="Nothing set yet..." />
<ext:Button ID="stopCounting" runat="server" Text="Stop counting">
<AjaxEvents><Click OnEvent="stopCounting_Click" /></AjaxEvents>
</ext:Button>
<asp:Timer ID="ruinScript" runat="server" OnTick="ruinScript_Tick" Interval="7500" Enabled="true"></asp:Timer>
<asp:Button ID="manualRuination" runat="server" Text="Never press this button" onclick="manualRuination_Click"/>
<asp:Label ID="resultOfTheRuination" runat="server" Text="Everyting ok" />
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>