No disrespect meant to anyone but ever since playing around with ASP.Net web controls I have a niggling feeling that something is not quite right. The feeling arises every time I come across HTML in compiled code.
- Placing HTML in code can be difficult to change especially for non-programmer designers,
- Placing HTML in code prevents separation of the web application layers. The programmer becomes responsible for logic AND presentation,
- Windows forms apps and web apps are clearly distinct paradigms, at least to me, is convergence really possible? Will Windows forms apps using a web deployment model, e.g.
ClickOnce, make web controls redundant?
Just some thoguhts,
I would try not to place html in the actual control, instead you can use an xslt files that generate the actual html output, so that the facade layer that the control talks to just outputs xml.
As far as I am aware there is no option to render ASP.Net web controls as XML, HTML is the only option. The System.Web.UI.Page method that is responsible for displaying the controls is:
In most cases it wouldn't make a lot of sense to render controls as XML. What it would make sense to render as XML is the content.
I notice there is talk of Master Templates in VS 2005 I am hoping this will move towards ASP.Net using a front controller instead of a page controller, such as in
Maverick.Net. This would facilitate a much cleaner separation in the web presentation layer.
Yes, the RenderControl method does use a HtmlTextWriter, but I'm not saying provide xml to that, but rather get sml from the facade layer (below the control) and the control can then use an xslt file to transform this into xHtml and write the result of
the transform to the HtmlTextWriter. This would mean that the site designer doesn't have to code the control. Of course this depends largely on what you want your control to do...
If you are saying that the Web Controls should be replaced with XSLT I agree whole heartedly. This has the effect of moving the HTML out of code and into a stylesheet.
In this case replacing is really removing since the main function of the Web Controls is to produce the HTML. If you have the content XML then XSLT can be used instead of binding to a Web Control. I use ASP.Net without Web Controls.
I don't really see what you are referring to as the facade layer - perhaps System.Web.UI.Control - but in most cases it wouldn't make sense to get XML from it. For instance the XML for a checkbox or a textbox is fairly useless; it's the XML for the content
that is going to be used in the checkbox or textbox that is useful. This content XML would be provided by another layer that is completely separate from the Web Control.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.