Some Sitecore developers prefer using XSLT as a way of rendering content on a Sitecore website. It does allow a non- .NET Developer some really easy ways to render regular content pages but can become extremely complex once you start building dynamic pages with dynamic content. XSL also poses several performance issues as the site grows and thats where C# and .NET really comes handy.
In this post, I will talk about rendering
fields using .NET
code with web controls. This allows .NET
developers to enjoy the same simplicity of rendering
field types available in XSL, and it also supports the Page Editor.
One my favorite controls is Sitecore.Web.UI.WebControls.FieldRenderer web control. You can just specify the field name and the control will do the rest. If you wish to be more creative, you can use other optional parameters and have html render before and after the field value. FieldRenderer is registered as a web control rendering in Sitecore, and this allows power users to output different field types from the Page Designer too.You can also just use the Render method from the FieldRenderer class and you�d rather just get result as a string.
There are a bunch of other web controls that can be used to render specific field types like Date, Image, Link, etc.
If your goal is to also support the Page Editor, then you have to remember to use one of the above webcontrols to output field values. Just a regular Response.Write method will not go a long way.