J
J055
Hi
I want to make a simple modification to the BulletedList control. I would
like the control to render with a DIV element wrapped around it, e.g.
<div id="MessagesList1" class="messages">
<ul>
<li>Item 1</li>
</ul>
</div>
The control including the div should only render if the BulletedList
contains items.
I've had a go at overriding the render method
protected override void Render(HtmlTextWriter writer)
{
if (!DesignMode)
{
if (this.Items.Count > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class,
"messages");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
base.Render(writer);
writer.RenderEndTag();
}
}
else
{
base.Render(writer);
}
}
This works in the browser but It doesn't seem quite right in DesignMode. I
get the following error:
Error 1 Element 'ListItem' is not a known element. This can occur if there
is a compilation error in the Web site.
Also it would be better i think if the control ID was fixed against the div
tag, not the UL or OL.
What would be my best approach here?
Thanks
Andrew
I want to make a simple modification to the BulletedList control. I would
like the control to render with a DIV element wrapped around it, e.g.
<div id="MessagesList1" class="messages">
<ul>
<li>Item 1</li>
</ul>
</div>
The control including the div should only render if the BulletedList
contains items.
I've had a go at overriding the render method
protected override void Render(HtmlTextWriter writer)
{
if (!DesignMode)
{
if (this.Items.Count > 0)
{
writer.AddAttribute(HtmlTextWriterAttribute.Class,
"messages");
writer.RenderBeginTag(HtmlTextWriterTag.Div);
base.Render(writer);
writer.RenderEndTag();
}
}
else
{
base.Render(writer);
}
}
This works in the browser but It doesn't seem quite right in DesignMode. I
get the following error:
Error 1 Element 'ListItem' is not a known element. This can occur if there
is a compilation error in the Web site.
Also it would be better i think if the control ID was fixed against the div
tag, not the UL or OL.
What would be my best approach here?
Thanks
Andrew