Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Derived BulletedList

Reply
Thread Tools

Derived BulletedList

 
 
J055
Guest
Posts: n/a
 
      03-07-2007
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


 
Reply With Quote
 
 
 
 
J055
Guest
Posts: n/a
 
      03-07-2007
Hi

I've got behaving as I need in the browser now. Used the reflector tool to
get the TagKeyInternal method so the control would still work like the
BullettList. However I still get an error in design mode because it doesn't
recognise the LIstItems. BY the way I'm doing this so it copies the way the
ValidationSummary control renders. Then I only need one set of css styles
and they will always match when displayed side by side on a web page.

Thanks
Andrew


protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Div;
}
}

internal HtmlTextWriterTag TagKeyInternal
{
get
{
switch (this.BulletStyle)
{
case BulletStyle.NotSet:
return HtmlTextWriterTag.Ul;

case BulletStyle.Disc:
case BulletStyle.Circle:
case BulletStyle.Square:
return HtmlTextWriterTag.Ul;

case BulletStyle.CustomImage:
return HtmlTextWriterTag.Ul;
}
return HtmlTextWriterTag.Ol;
}
}

protected override void RenderContents(HtmlTextWriter writer)
{
writer.RenderBeginTag(TagKeyInternal);
base.RenderContents(writer);
writer.RenderEndTag();
}


 
Reply With Quote
 
 
 
 
Steven Cheng[MSFT]
Guest
Posts: n/a
 
      03-08-2007
Hi Andrew,

Regarding on the custom BulledList control that need an additional <div>
wrapper tag, I think your current implementation is reasonable. As for the
design-time error, it is actually due to the schema validation. Since your
custom BulletedList control's control tag hasn't been in the built-in aspx
control schema, when you add <asp:ListItem> tags into your custom
<cc1:MyBulletedList> tag, the IDE will report such design-time validation
error. This is an expected behavior for most custom controls which will
include other built-in control's inner tag as its own child tag element.
Anyway, I think you can simply ignore it as the runtime control since it
doesn't affect any of the runtime control lifecycle or processing.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead



==================================================

Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.



Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.

==================================================



This posting is provided "AS IS" with no warranties, and confers no rights.



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Derived Structure in Derived Class?? David C++ 3 01-29-2008 07:38 AM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 01:44 PM
Derived::Derived(const Base&) developereo@hotmail.com C++ 4 05-23-2007 09:32 AM
Derived::Derived(const Base&) and Derived& operator=(const Base&) developereo@hotmail.com C++ 1 05-23-2007 12:07 AM
BulletedList inside BulletedList Stan SR ASP .Net 2 08-31-2006 05:36 AM



Advertisments