Creating HTML markup using HTML Controls object model

Although ASP.NET provides a great object model for handling Web Controls and HTML Controls, I often see code that creates HTML markup directly, by manipulating strings. An example:   private string GetSomeHtml()  {    string html = “<A HREF=\”http://blogs.msdn.com/aribeiro\”>” + Server.HtmlEncode(“Antonio Ribeiro’s Web Log”) + “</A>”;    return html;  } Despite being performant, this isn’t easy to read or to…

2

Rendering n-column tables using the Repeater control

The ASP.NET Repeater control provides a template-based mechanism for rendering data using Data Binding. A basic usage sample can be found here . The control uses the <ItemTemplate> tag for declaring HTML that should be rendered for each data item and a <SeparatorTemplate> tag to put some HTML between items. It also supports an <AlternatingItemTemplate> that…

1

New articles available !

Check Creating a Custom Placeholder to render and edit XML data using XSL templates (CMS) and Rendering n-column tables using the Repeater control (ASP.NET)    


Creating a Custom Placeholder to render and edit XML data using XSL templates

XMLPlaceholder Controls are a useful technique to handle structured data within a CMS Posting. Suppose you have a Book template containing an Authors placeholder. When a book has more than one author, you could store a comma-separated list of authors in a HtmlPlaceholder. The authoring interface would look like: Authors List: But ideally, the list…

1