替代的HtmlTextWriter在System.Web.UI.Control? [英] Alternatives to HtmlTextWriter in a System.Web.UI.Control?
本文介绍了替代的HtmlTextWriter在System.Web.UI.Control?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您可以使用FluentHTML或其他替代品在Web应用程序中的用户控件?
Can you use FluentHTML or other alternatives in an web application user control?
你能放一个标记文件中像System.Web.UI.UserControl一个System.Web.UI.Control但没有Page对象的负担?
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?
我想,以减少下列code的行数:
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
感谢
推荐答案
我开发我自己的助手工具,现在我可以写标记是这样的:
I developed my own helper tools, now i can write markup this way:
using (new Xhtml.BlockTags.Body(writer))
{
using (new Xhtml.BlockTags.Div("layout", string.Empty, true, writer))
{
using (new Xhtml.BlockTags.Div("header", string.Empty, writer))
{
_header.Render(writer);
}
using (new Xhtml.BlockTags.Div("content", string.Empty, writer))
{
_content.Render(writer);
}
AjaxStatus.Render(writer);
}
}
在这个例子中,一个blocktag的第一个参数是ID,第二类,以写入的最后一个参考
in this example, the first parameter of a blocktag is the ID, the second the class, the last a reference to the writer
这篇关于替代的HtmlTextWriter在System.Web.UI.Control?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文