Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Building Controls / June 2007

Tip: Looking for answers? Try searching our database.

Overriding renderBeginTag is bad?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
TS - 06 Jun 2007 17:36 GMT
If i have a control that inherits from a class in Webcontrols (ie textbox)
and then overrides RenderBeginTag, isn't this not recommended since the
UI/Browser specific web attributes won't get set by framework? I always read
that you should override renderContents instead of the combination of
renderBeginTag, Render, RenderEndTag for this reason.

Does anyone agree or disagree?

thanks!
TS - 06 Jun 2007 17:41 GMT
I guess maybe if you call the base implementation inside the render methods,
these UI/browser attributes would get set and no issues would be seen?

> If i have a control that inherits from a class in Webcontrols (ie textbox)
> and then overrides RenderBeginTag, isn't this not recommended since the
[quoted text clipped - 5 lines]
>
> thanks!
Walter Wang [MSFT] - 07 Jun 2007 06:39 GMT
Hi TS,

I think this will depend on what's the design objective of your control.
The default implementation of RenderBeginTag will render the control's open
tag. If you need to completely control how the resulting HTML, feel free to
override it.

Please feel free to let me know your detailed requirement of the control so
that we can further discuss it. Thanks.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
TS - 07 Jun 2007 19:09 GMT
well my point is that i am just curious whether UI/Browser specific web
attributes won't get set by framework in this implementation

> Hi TS,
>
[quoted text clipped - 16 lines]
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
TS - 11 Jun 2007 13:48 GMT
can you confirm this statement in my last post?

> well my point is that i am just curious whether UI/Browser specific web
> attributes won't get set by framework in this implementation
[quoted text clipped - 23 lines]
> > This posting is provided "AS IS" with no warranties, and confers no
> rights.
Walter Wang [MSFT] - 12 Jun 2007 12:42 GMT
Hi TS,

Sorry for the delay.

Based on my understanding, your question is actually about how ASP.NET
renders differently for different browser/device.

If you take a look at the WebControl.RenderBeginTag using Reflector
(http://www.aisto.com/roeder/dotnet/), you will see it's calling into the
HtmlTextWriter.RenderBeginTag to do the rendering. The default
HtmlTextWriter renders HTML 4.0-compliant markup; and the Html32TextWriter,
which renders HTML 3.2-compliant markup. (The Html32TextWriter class is
derived from the HtmlTextWriter class)

When the Page class enters its render stage, it starts by creating a new
HtmlTextWriter instance. It determines what class instance to create -
HtmlTextWriter or Html32TextWriter - by inspecting the TagWriter property
of the Browser object. The Browser object contains read-only properties
that provides information about the browser that was used to request the
page. A web browser is identified by its User-Agent string.

Whenever a Web browser requests a page, it sends along a User-Agent string
in the HTTP headers that is used to identify the browser. The ASP.NET
engine examines the User-Agent string to determine the value for the
Browser's properties.

Therefore for your original question about overriding
WebControl.RenderBeginTag, as long as you're using the HtmlTextWriter
reference to output the text, it should still be adaptive for different
browser/device.

Hope this helps. Please feel free to let me know if there's anything
unclear. Thanks.

Regards,
Walter Wang (wawang@online.microsoft.com, remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.