Alternatives to HtmlTextWriter in a System.Web.UI.Control?

Posted by Marco Bettiolo on Stack Overflow See other posts from Stack Overflow or by Marco Bettiolo
Published on 2010-03-10T21:02:29Z Indexed on 2010/03/22 1:21 UTC
Read the original article Hit count: 494

Filed under:
|

Hi, Can you use FluentHTML or other alternatives in an web application user control?

Can you put a markup file in a System.Web.UI.Control like the System.Web.UI.UserControl but without the burden of the Page object?

I would like to reduce the number of lines of the following code:

writer.Write(SacrificalMarkupPage.GenerateControlMarkup(new DialogConfirm()));

writer.AddAttribute("class", string.Format("ajaxResponse {0}", action));
writer.RenderBeginTag("div");

writer.RenderBeginTag("h4");
writer.WriteEncodedText("Delete selected item?");
writer.RenderEndTag(); //h4

var queryString = new HttpQueryString
  {
    {"confirmed", "true"},
    {"src", urlReferer.PathAndQuery}
  };

writer.AddAttribute("href", queryString.MakeQueryString(url).PathAndQuery);
writer.AddAttribute("class", "delete");
writer.RenderBeginTag("a");
writer.WriteEncodedText("Yes");
writer.RenderEndTag(); //a.delete

writer.WriteEncodedText(" | ");

writer.AddAttribute("href", urlReferer.PathAndQuery);
writer.AddAttribute("class", "back");
writer.RenderBeginTag("a");
writer.WriteEncodedText("No");
writer.RenderEndTag(); //a.back

writer.RenderEndTag(); //div.ajaxResponse.ACTION

Thanks

© Stack Overflow or respective owner

Related posts about htmltextwriter

Related posts about ASP.NET