简体   繁体   中英

how can I prevent my custom element from getting its own div?

I have created a custom C# object that inherits ScriptControl and INamingContainer . All it has are some spans inside. When I place it on my page, it gets its own div, which I don't want. Is there a property or something I can set to force it to be created as a span instead?

You could override protected TagKey property of your control; it gets the HtmlTextWriterTag value that corresponds to this Web server control:

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

try this

 protected override HtmlTextWriterTag TagKey
 {
     get 
     {
          // return elmement that you would like  HtmlTextWriterTag.Span for instance.
     }
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM