CustomControls inherented from CompositeControl allways have as tag span - how to change this

R

Rolf Welskes

Hello,
When developing Customcontrols which have other controls it seems be good
practice to inherent from CompositeControl.

But other as at WebControl I am not able to set the tag of the control. It's
allways span.

If you now build such a control - as also in an example from the msnd - with
for example a table in it you have the following:

<span> <table>.....</table></span> as generated html.

This is bad html because span is an inline-element and can only have
inline-elements - but - table is a block-element.

So this problem would not be there if you can set the tag you need for
example to div in the constructor of the control
as it is possible in WebControl.

So question : what is to do in this case.

Thank you for any help.
Rolf Welskes
 
W

Walter Wang [MSFT]

Hi Rolf,

You can override the TagKey property:

public class Class1 : CompositeControl
{
protected override HtmlTextWriterTag TagKey
{
get
{
return HtmlTextWriterTag.Div;
}
}
}

Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

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/subscriptions/support/default.aspx.
==================================================

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,535
Members
45,008
Latest member
obedient dusk

Latest Threads

Top