本文整理汇总了C#中TagBuilder.End方法的典型用法代码示例。如果您正苦于以下问题:C# TagBuilder.End方法的具体用法?C# TagBuilder.End怎么用?C# TagBuilder.End使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TagBuilder
的用法示例。
在下文中一共展示了TagBuilder.End方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderItem
string RenderItem(Item originalItem, bool includeTop)
{
Item item = originalItem;
string fieldName = Parameters["image"];
if (!string.IsNullOrEmpty(fieldName))
{
ImageField field = originalItem.Fields[fieldName];
Assert.IsNotNull(field, "The item {0} does not have an image field '{1}'. Check visual list field source.".FormatWith(originalItem.Paths.ContentPath, fieldName));
if (field.MediaItem != null)
{
item = field.MediaItem;
}
}
var output = new HtmlTextWriter(new StringWriter());
string url;
if (item.Paths.IsMediaItem)
{
MediaItem media = item;
// Look for image width (w) & height (h) parameters
int iWidth = 96;
int iHeight = 96;
if (!String.IsNullOrEmpty(Parameters["w"]))
iWidth = int.Parse(Parameters["w"]);
if (!String.IsNullOrEmpty(Parameters["h"]))
iHeight = int.Parse(Parameters["h"]);
var options = new MediaUrlOptions(iWidth, iHeight, true);
url = "/sitecore/shell/" + MediaManager.GetMediaUrl(media, options);
}
else
{
url = Images.GetThemedImageSource(item.Appearance.Icon, ImageDimension.id48x48);
}
TagBuilder li = null;
if (includeTop)
{
li = new TagBuilder("li") { ID = originalItem.ID.ToString() }.Start(output);
}
var container = new TagBuilder("div") { Class = "image-container" };
if (!item.Paths.IsMediaItem)
{
container.Class += " small";
}
container.Start(output);
new TagBuilder("img").Add("src", url).Add("align", "middle").ToString(output);
container.End(output);
new TagBuilder("span") { Class = "text", InnerHtml = GetText(originalItem) }.ToString(output);
output.Write("<div class=\"delete\"></div>");
if (includeTop)
{
li.End(output);
}
return output.InnerWriter.ToString();
}
示例2: RenderItem
void RenderItem(HtmlTextWriter output, Item originalItem) {
var item = originalItem;
var fieldName = Parameters["image"];
if (!string.IsNullOrEmpty(fieldName)) {
ImageField field = originalItem.Fields[fieldName];
Assert.IsNotNull(field, "The item {0} does not have an image field '{1}'. Check carousel field source.".FormatWith(originalItem.Paths.ContentPath, fieldName));
if (field.MediaItem != null) {
item = field.MediaItem;
}
}
string url;
if (item.Paths.IsMediaItem) {
MediaItem media = item;
var options = new MediaUrlOptions(96, 96, true);
url = "/sitecore/shell/" + MediaManager.GetMediaUrl(media, options);
}
else {
url = Images.GetThemedImageSource(item.Appearance.Icon, ImageDimension.id48x48);
}
var li = new TagBuilder("li") { ID = originalItem.ID.ToString() };
if (originalItem.ID.ToString() == WebUtil.GetQueryString("v")) {
li.Class = "selected";
}
li.Start(output);
var container = new TagBuilder("div") { Class = "image-container" };
if (!item.Paths.IsMediaItem) {
container.Class += " small";
}
container.Start(output);
new TagBuilder("img").Add("src", url).ToString(output);
container.End(output);
new TagBuilder("span") { Class = "text", InnerHtml = GetText(originalItem)}.ToString(output);
li.End(output);
}