Hi, I am not sure if I completely grasp the difference in meaning of overriding WebControl.RenderBeginTag(HtmlTextWriter) and overriding Control.TagName. For a custom control that inherits from an existing .NET server control, it has access to both of them.
So if I want to change the beginning of the rendering of my custom control, which one should I override? Should they be mutually exclusive where you should only use one but not both at one time in your custom control? I understand that when I write my own
own MyCustomControl : .NET Server Control, if I don't like it being wrapped with a
tag, I can override TagKey. If I cannot find my tag in HtmlTextWriterTag, ie. I have a weird begin tag, I can override TagName, meaning TagKey and TagName should be mutually exclusive. But I struggle the difference between RenderBeginTag() and TagName...
Experts please?
Hi, You are right, RenderBeginTag implementation of WebControl use RenderBeginTag method of HtmlTextWriter to render opening tag by TagKey or, if it is not recognized, by TagName. It adds attributes and styles to HTML element in process. Usually it is enough
to override TagKey or TagName in custom control. You should override RenderBeginTag only if very unusual, odd rendering required.
Yes, whatever he said :-) . The difference is, well... which one is easier to determine the tags in your code? Of course it will be with the overriding of the TagKey property... the RenderBeginTag method is there only for extreme cases.
sTe810
Member
650 Points
130 Posts
Difference between overriding WebControl.RenderBeginTag() and Control.TagName
Jan 20, 2005 07:55 PM|LINK
llangleyben
Star
8315 Points
1660 Posts
MVP
Re: Difference between overriding WebControl.RenderBeginTag() and Control.TagName
Jan 30, 2005 11:27 AM|LINK
MCSD, ASP.NET MVP
Blog
master4eva
Star
13635 Points
2719 Posts
Re: Difference between overriding WebControl.RenderBeginTag() and Control.TagName
Feb 06, 2005 05:11 AM|LINK