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

Discussion in 'ASP .Net' started by Rolf Welskes, Oct 4, 2006.

  1. Rolf Welskes

    Rolf Welskes Guest

    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
     
    Rolf Welskes, Oct 4, 2006
    #1
    1. Advertising

  2. Hi Rolf,

    You can override the TagKey property:

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

    Sincerely,
    Walter Wang (, 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.
     
    Walter Wang [MSFT], Oct 5, 2006
    #2
    1. Advertising

  3. Rolf Welskes

    Rolf Welskes Guest

    Hello,
    thank you, it works fine.

    Thank you again.
    Rolf Welskes



    "Walter Wang [MSFT]" <> schrieb im Newsbeitrag
    news:...
    > Hi Rolf,
    >
    > You can override the TagKey property:
    >
    > public class Class1 : CompositeControl
    > {
    > protected override HtmlTextWriterTag TagKey
    > {
    > get
    > {
    > return HtmlTextWriterTag.Div;
    > }
    > }
    > }
    >
    > Sincerely,
    > Walter Wang (, 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.
    >
     
    Rolf Welskes, Oct 5, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Shapper
    Replies:
    1
    Views:
    365
    Craig Deelsnyder
    Jun 19, 2005
  2. shruds
    Replies:
    1
    Views:
    843
    John C. Bollinger
    Jan 27, 2006
  3. Goofy
    Replies:
    2
    Views:
    272
  4. Replies:
    6
    Views:
    618
    Victor Bazarov
    Oct 20, 2005
  5. Replies:
    9
    Views:
    404
    Daniel T.
    Oct 17, 2006
Loading...

Share This Page