PDA

View Full Version : [FIXED] Panel/Fieldset bug



Tech0
Apr 07, 2008, 5:15 PM
Hi devs,

I love your controls and use them in my application. But I found a problem. When I add a Panel or FieldSet from codebehind the panel is not showing and browser throwns a javascript error.
"this.el.dom is null or not an object"

Thanks in advance


Regards,

Ivaylo

geoffrey.mcgill
Apr 14, 2008, 1:48 PM
Do you have a ScriptManager control on the Page?

The following samples demonstrate addeding a Panel and Fieldset from the code-behind. Examples for both version 0.4 and the soon to be released 0.5 are included.

Example (0.4)


<%@ Page Language="C#" %>
<%@ Register Assembly="Coolite.Web.UI" Namespace="Coolite.Web.UI" TagPrefix="cool" %>

<!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)
{
Coolite.Web.UI.Panel panel = new Coolite.Web.UI.Panel();

panel.ID = "Panel1";
panel.Title = "Panel";
panel.Width = Unit.Pixel(400);
panel.Height = Unit.Pixel(300);
panel.Collapsible = true;
panel.BodyStyle = "padding:6px;";

FieldSet fieldset = new FieldSet();
fieldset.ID = "Fieldset1";
fieldset.Title = "Fieldset";
fieldset.Height = Unit.Pixel(250);
fieldset.Collapsible = true;

LiteralControl div = new LiteralControl();
div.Text = "Hello World";

// Add to Fieldset
fieldset.ContentContainer.Controls.Add(div);

// Add Fieldset to Panel
panel.ContentContainer.Controls.Add(fieldset);

// Add Panel to Form
this.form1.Controls.Add(panel);
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<cool:ScriptManager ID="ScriptManager1" runat="server" />
</form>
</body>
</html>


Example (0.5)


<%@ 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)
{
Coolite.Ext.Web.Panel panel = new Coolite.Ext.Web.Panel();

panel.ID = "Panel1";
panel.Title = "Panel";
panel.Width = Unit.Pixel(400);
panel.Height = Unit.Pixel(300);
panel.Collapsible = true;
panel.BodyStyle = "padding:6px;";

FieldSet fieldset = new FieldSet();
fieldset.ID = "Fieldset1";
fieldset.Title = "Fieldset";
fieldset.Height = Unit.Pixel(250);
fieldset.Collapsible = true;

LiteralControl div = new LiteralControl();
div.Text = "Hello World";

// Add to Fieldset
fieldset.Items.Add(div);

// Add Fieldset to Panel
panel.Items.Add(fieldset);

// Add Panel to Form
this.form1.Controls.Add(panel);
}
</script>

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


Hope this helps.