PDA

View Full Version : [CLOSED] Coolite.Utilities Assembly ?



Timothy
Sep 15, 2008, 10:52 AM
Hello,

Curious what changes in the last check in for Coolite.Utilities assembly? Currently not working with other 3rd party controls.

I've noticed in a few places in the Coolite project, you do a condition check to see if its a Ext control using the following:



if (control != System.Web.UI.WebControl) { ... }


Here is the exception I'm getting:


[InvalidCastException: Unable to cast object of type 'Telerik.Web.UI.GridTableRow' to type 'Telerik.Web.UI.GridItem'.]
Telerik.Web.UI.GridTableRow.get_ClientID() +86
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +185
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindControlByTypeNa me(Control seed, String typeFullName, Boolean shallow, Boolean traverse, Control branch) +423
Coolite.Utilities.ControlUtils.FindControl(Control seed, Type type, Boolean shallow) +55
Coolite.Utilities.ControlUtils.FindControl(Control seed, Type type) +32
Coolite.Ext.Web.ScriptManager.get_ScriptContainer( ) +61
Coolite.Ext.Web.ScriptManager.Page_PreRenderComple te(Object sender, EventArgs e) +89
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2063008
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2247



Timothy

geoffrey.mcgill
Sep 15, 2008, 11:11 AM
Hi Timothy,

Can you explain the scenario in more detail? Are you calling into the Coolite.Utilities assembly, or is that stack-trace/exception just being thown by the Toolkit? Can you post a simplified code sample?

Timothy
Sep 15, 2008, 11:18 AM
I'm not calling it directly, the stack shows the function is being called internally. I just have a Telerik control inside a Ext:TabPanel.

Would you be willing to expose the Coolite.Utilities code and I can debug?

Cheers,
Timothy

Timothy
Sep 15, 2008, 11:39 AM
Hmm, I didn't think I would be able to pull an example off so easily:

Example.aspx:


<%@ 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 Page_Load(object sender, EventArgs e)
{
dgWord.Rebind();
}

protected void dgWord_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
dgWord.DataSource = new object[] { "Word", "Word" };
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<p><a href="Example.aspx">Reload</a></p>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="True" />
<ext:ScriptManager runat="server" Theme="Gray" />

<ext:TabPanel ID="TabPanel1" runat="server" ActiveTabIndex="0" AutoPostBack="True" AutoHeight="True" AutoWidth="True" DeferredRender="True">
<Tabs>
<ext:Tab ID="Tab1" runat="server" Title="Tab 1">
<Content>
Content 1
</Content>
</ext:Tab>
<ext:Tab ID="Tab2" runat="server" Title="Tab 2">
<Content>
<Telerik:RadGrid ID="dgWord" runat="server" OnNeedDataSource="dgWord_NeedDataSource" AutoGenerateColumns="False" SkinID="Default" Width="800">
<MasterTableView runat="server" AllowNaturalSort="True" AllowPaging="True" AllowSorting="True" CommandItemDisplay="Bottom" PageSize="10" TableLayout="Fixed">
<CommandItemStyle HorizontalAlign="Right" />
<CommandItemTemplate>
<ExtJS:Button ID="btnAdd" runat="server" Text="Add" MinWidth="60" StyleSpec="margin: 5px; width: 60px;" />
</CommandItemTemplate>
<Columns>
<Telerik:GridTemplateColumn>
<ItemTemplate>
Word
</ItemTemplate>
</Telerik:GridTemplateColumn>
</Columns>
<NoRecordsTemplate>
Nadda
</NoRecordsTemplate>
</MasterTableView>
<PagerStyle AlwaysVisible="True" Mode="NextPrev" Width="100%" />
</Telerik:RadGrid>
</Content>
</ext:Tab>
</Tabs>
</ext:TabPanel>

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


Exception:


[InvalidCastException: Unable to cast object of type 'Telerik.Web.UI.GridTableRow' to type 'Telerik.Web.UI.GridItem'.]
Telerik.Web.UI.GridTableRow.get_ClientID() +86
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +185
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindChildControl(Co ntrol seed, String typeFullName, Boolean shallow) +251
Coolite.Utilities.ControlUtils.FindControlByTypeNa me(Control seed, String typeFullName, Boolean shallow, Boolean traverse, Control branch) +423
Coolite.Utilities.ControlUtils.FindControl(Control seed, Type type, Boolean shallow) +55
Coolite.Utilities.ControlUtils.FindControl(Control seed, Type type) +32
Coolite.Ext.Web.ScriptManager.get_ScriptContainer( ) +61
Coolite.Ext.Web.ScriptManager.Page_PreRenderComple te(Object sender, EventArgs e) +89
System.EventHandler.Invoke(Object sender, EventArgs e) +0
System.Web.UI.Page.OnPreRenderComplete(EventArgs e) +2063008
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2247


Cheers,
Timothy

Timothy
Sep 15, 2008, 11:42 AM
Wow, also happens when its the only control on the page ;)

Example.aspx:


<%@ 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 Page_Load(object sender, EventArgs e)
{
dgWord.Rebind();
}

protected void dgWord_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
dgWord.DataSource = new object[] { "Word", "Word" };
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Untitled Page</title>
</head>
<body>
<p><a href="Example.aspx">Reload</a></p>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" EnablePartialRendering="True" />
<ext:ScriptManager runat="server" Theme="Gray" />


<Telerik:RadGrid ID="dgWord" runat="server" OnNeedDataSource="dgWord_NeedDataSource" AutoGenerateColumns="False" SkinID="Default" Width="800">
<MasterTableView runat="server" AllowNaturalSort="True" AllowPaging="True" AllowSorting="True" CommandItemDisplay="Bottom" PageSize="10" TableLayout="Fixed">
<CommandItemStyle HorizontalAlign="Right" />
<CommandItemTemplate>
<ExtJS:Button ID="btnAdd" runat="server" Text="Add" MinWidth="60" StyleSpec="margin: 5px; width: 60px;" />
</CommandItemTemplate>
<Columns>
<Telerik:GridTemplateColumn>
<ItemTemplate>
Word
</ItemTemplate>
</Telerik:GridTemplateColumn>
</Columns>
<NoRecordsTemplate>
Nadda
</NoRecordsTemplate>
</MasterTableView>
<PagerStyle AlwaysVisible="True" Mode="NextPrev" Width="100%" />
</Telerik:RadGrid>


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

Timothy
Sep 15, 2008, 11:44 AM
Just wanted to throw this in; this didn't happen as of revision 348 to \Coolite.Ext.Web\Build\Resources\ReferenceAssembli es\Coolite.Utilities\Coolite.Utilities.dll but was introduced on 351 :)

Hope that helps narrow it down for you!

Cheers,
Timothy

geoffrey.mcgill
Sep 15, 2008, 12:41 PM
I added the Coolite.Utilities Project to the main .sln. 

I ran a couple tests using other 3rd party controls within your sample (not Telerik) and did not run into the Exception. I stepped through the code and it appears to be correct, but who know's what might be triggering the error. There must be something obvious in there that I'm missing. 


Do an SVN update and retry with the new Utilties assembly. If the exception is thrown, please set a breakpoint on ControlUtils.cs FindChildControl(Control seed, string typeFullName, bool shallow) approx line #210. Step through the code and let me know if you hit the error.


The Coolite.Utilities project is generic and can be used with any control/library. There's no requirement to Reference or only use with Coolite/Ext controls. 

Timothy
Sep 15, 2008, 12:43 PM
Thanks, will let you know.

Cheers,
Timothy

Timothy
Sep 15, 2008, 1:28 PM
OK, I debugged it and I've come to the following conclusion:

What is the purpose of:



tempClientID = control.ClientID ?? "";


On line 222 in ControlUtils.cs?

The variable is not used and is the culprit for throwing the exception.

Cheers,
Timothy

geoffrey.mcgill
Sep 15, 2008, 1:51 PM
ok, delete that line and see what happens. It's not required, but I'm at a loss to explain why any Control would fail on that line. Maybe Telerik has overridden the .ClientID property within their controls and is performing some kind of type check internally which is throwing the Exception. There's really no reason calling .ClientID should throw that kind of Exception... but, I always reserve the right to change my mind. ;)

Can you use Reflector to figure out if they're messing around with the .ClientID property of GridTableRow or GridItem class?

Timothy
Sep 15, 2008, 2:01 PM
Was just on Teleriks website and found the following in their latest release:



...
Fixed an exception in GridTableRow.ClientID
...


Please ignore my post, perhaps keep this in mind for the future if you have a problem with them.

Cheers,
Timothy

geoffrey.mcgill
Sep 15, 2008, 2:20 PM
Good know. Thanks for the update.