当前位置: 首页>>代码示例>>C#>>正文


C# TagBuilder.Start方法代码示例

本文整理汇总了C#中TagBuilder.Start方法的典型用法代码示例。如果您正苦于以下问题:C# TagBuilder.Start方法的具体用法?C# TagBuilder.Start怎么用?C# TagBuilder.Start使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TagBuilder的用法示例。


在下文中一共展示了TagBuilder.Start方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DoRender

    /// <summary>
    /// Sends server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter"></see> object, which writes the content to be rendered on the client.
    /// </summary>
    /// <param name="output">The <see cref="T:System.Web.UI.HtmlTextWriter"></see> object that receives the server control content.</param>
    protected override void DoRender(HtmlTextWriter output) {
      Item current = Client.GetItemNotNull(ItemID, Sitecore.Context.ContentDatabase);
      IList<Item> items = GetItems(current, Source);

      var list = new TagBuilder("div") {ID = ID, Class = "scTextlist"};
      if(Disabled) {
        list.Add("disabled", "true");
      }

      list.Start(output);

      output.Write("<div id='{0}_list' class='textlist-list'>".FormatWith(ID));

      RenderValue(output);

      output.Write("</div>");

      output.Write("<div class='textlist-autocomplete' style='display:none'></div>");

      output.Write("<div class='textlist-choices' style='display:none'>");

      foreach(Item item in items) {
        output.Write("<span sc_text=\"{0}\" sc_value='{1}'>{0}</span>".FormatWith(item.DisplayName, item.ID));
      }

      output.Write("</div>");
      output.Write("</div>");

      output.Write("<input type='hidden' id='{0}' value='{1}' />".FormatWith(ID + "_value", Value));

      output.Write("<link rel=Stylesheet type='text/css' href='/sitecore%20modules/outercore.fieldtypes/textlist/js/textlist.css' />");

      string script = "new Sitecore.FieldTypes.TextList('{0}');".FormatWith(ID);
      script = "<script type='text/javascript' language='javascript'>" + script + "</script>";
      output.Write(script);
    }
开发者ID:adeneys,项目名称:Outercore.FieldTypes,代码行数:40,代码来源:TextListContentField.cs

示例2: 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();
        }
开发者ID:agriffit,项目名称:Outercore.FieldTypes,代码行数:69,代码来源:VisualList.Frame.xaml.xml.cs

示例3: RenderItems

        void RenderItems()
        {
            var items = GetItems();
            var output = new HtmlTextWriter(new StringWriter());

            output.Write("\r\n");
            var ul = new TagBuilder("ul") { ID = "list" };
            if (Disabled)
            {
                ul.Class = "disabled";
            }

            ul.Start(output);
            output.Write("\r\n");

            RenderItems(output, items);

            output.Write("</ul>");

            Items.InnerHtml = output.InnerWriter.ToString();
        }
开发者ID:agriffit,项目名称:Outercore.FieldTypes,代码行数:21,代码来源:VisualList.Frame.xaml.xml.cs

示例4: RenderCarousel

    void RenderCarousel() {
      var currentItem = GetItem();
      if (currentItem == null) {
        Items.InnerHtml = "<strong>Current item not found</strong>";
        return;
      }

      var items = LookupSources.GetItems(GetItem(), Source);
      var output = new HtmlTextWriter(new StringWriter());

      var ul = new TagBuilder("ul");
      if (Disabled) {
        ul.Class = "disabled";
      }

      ul.Start(output);
      RenderItems(output, items);
      output.Write("</ul>");

      Items.InnerHtml = output.InnerWriter.ToString();
    }
开发者ID:adeneys,项目名称:Outercore.FieldTypes,代码行数:21,代码来源:Carousel.Frame.xaml.xml.cs

示例5: 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);
    }
开发者ID:adeneys,项目名称:Outercore.FieldTypes,代码行数:45,代码来源:Carousel.Frame.xaml.xml.cs


注:本文中的TagBuilder.Start方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。