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


C# IHtmlString类代码示例

本文整理汇总了C#中IHtmlString的典型用法代码示例。如果您正苦于以下问题:C# IHtmlString类的具体用法?C# IHtmlString怎么用?C# IHtmlString使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CacheRenderedTag

        internal static void CacheRenderedTag(string virtualPath, IHtmlString renderedTag)
        {
            RenderedTags[virtualPath] = renderedTag;

            var ctx = HttpContext.Current;
            var physicalPath = ctx.Server.MapPath(virtualPath);
            if (File.Exists(physicalPath))
            {
                // add file watcher
                var fsw = new FileSystemWatcher(
                    Path.GetDirectoryName(physicalPath), Path.GetFileName(physicalPath));
                FileSystemWatchers.Add(fsw);

                // remove from lookup on change, to allow for creation of new md5 hash
                fsw.Renamed += (sender, args) =>
                {
                    RenderedTags.Remove(virtualPath);
                };
                fsw.Changed += (sender, args) =>
                {
                    RenderedTags.Remove(virtualPath);
                };
                fsw.Deleted += (sender, args) =>
                {
                    RenderedTags.Remove(virtualPath);
                };
                fsw.Created += (sender, args) =>
                {
                    RenderedTags.Remove(virtualPath);
                };

                fsw.EnableRaisingEvents = true;
            }
        }
开发者ID:carsales,项目名称:johnnycache,代码行数:34,代码来源:Common.cs

示例2: InsertAttributes

    /// <summary>
    /// Inserts the given attributes at the end of all opening tags in this HtmlString.
    /// </summary>
    /// <param name="htmlString">The HTML string.</param>
    /// <param name="attributeValues">The attribute values.</param>
    /// <exception cref="System.NullReferenceException"></exception>
    /// <exception cref="System.ArgumentException">No opening tag in IHtmlString: {0} + html;htmlString</exception>
    private static IHtmlString InsertAttributes(IHtmlString htmlString, IEnumerable<Tuple<string, object>> attributeValues)
    {
        if (htmlString == null) throw new NullReferenceException();

        var attributes = new StringBuilder();
        foreach (var t in attributeValues)
        {
            attributes.AppendFormat(" {0}=\"{1}\"",
                HttpUtility.HtmlEncode(t.Item1).ToLower(),
                HttpUtility.HtmlEncode((t.Item2 ?? String.Empty).ToString()));
        }

        var html = htmlString.ToHtmlString();

        var matches = GetOpeningTagMatches(html);
        if (matches.Count == 0)
            throw new ArgumentException("No opening tag in IHtmlString: {0}" + html, "htmlString");

        foreach (Match match in matches)
        {
            var endOfOpeningTag = match.Groups[3].Index;
            html = html.Insert(endOfOpeningTag, attributes.ToString());
        }

        return new HtmlString(html);
    }
开发者ID:raziqyork,项目名称:UsefulCode,代码行数:33,代码来源:HtmlStringExtensions.cs

示例3: HasTag

 protected bool HasTag(IHtmlString html, string tag)
 {
     var doc = new HtmlDocument();
     doc.LoadHtml(html.ToHtmlString());
     var xpath = "//" + tag;
     return doc.DocumentNode.SelectSingleNode(xpath) != null;
 }
开发者ID:jv9,项目名称:MvcReportViewer,代码行数:7,代码来源:IframeTests.cs

示例4: Concact

 public static IHtmlString Concact(this IHtmlString html, IHtmlString other)
 {
     StringBuilder sb = new StringBuilder();
     sb.Append(html.ToString());
     sb.Append(other.ToString());
     return new HtmlString(sb.ToString());
 }
开发者ID:cairabbit,项目名称:daf,代码行数:7,代码来源:HtmlStringExtensions.cs

示例5: FlowFormField

        public FlowFormField(TextWriter writer, bool containsSection, string labelHtml, string elementHtml, string errorHtml = "", bool isValid = true, IHtmlString hint = null, string tip = null, bool hideTip = true, string hintClass = null, string parentClass = null, bool displayFieldName = true)
        {
            _containsSection = containsSection;
            _writer = writer;

            var generatedSection = HelperDefinitions.BeginField(containsSection, displayFieldName ? new HtmlString(labelHtml) : null, new HtmlString(elementHtml), new HtmlString(errorHtml), isValid, hint, tip, hideTip, hintClass, parentClass);
            _writer.Write(generatedSection.ToHtmlString());
        }
开发者ID:SharePointSusan,项目名称:Research-Data-Manager,代码行数:8,代码来源:FlowFormField.cs

示例6: Truncate

 public static object Truncate(IHtmlString htmlString, int length)
 {
     if (htmlString.ToHtmlString().Length <= length)
     {
         return htmlString.ToHtmlString();
     }
     return htmlString.ToHtmlString().Substring(0, length) + "...";
 }
开发者ID:fitba,项目名称:km-2013-projects-team-majevica,代码行数:8,代码来源:HtmlHelpers.cs

示例7: LabelAndControl

 public LabelAndControl(ViewContext viewContext, string labelFor, string labelText, IHtmlString control)
 {
     _labelFor = labelFor;
     _labelText = labelText;
     _control = control;
     _formLayout = viewContext.TempData["BootstrapFormLayout"].ToString();
     HtmlAttributes["class"] = "control-group";
 }
开发者ID:jordanwallwork,项目名称:bootstrapextensions,代码行数:8,代码来源:LabelAndControl.cs

示例8: CreateField

        public static IHtmlString CreateField(this HtmlHelper html, string title, IHtmlString input, IHtmlString validation = null)
        {
            var result = string.Format(@"<div class=""control-group""><label for=""control-label"">{0}</label><div class=""controls"">{1}</div></div>", title, input);
            if (validation != null) {
                result = string.Format(@"<div class=""control-group""><label for=""control-label"">{0}</label><div class=""controls"">{1}<p>{2}</p></div></div>", title, input, validation);
            }

            return new HtmlString(result);
        }
开发者ID:tylermercier,项目名称:mvc_template,代码行数:9,代码来源:HtmlHelpers_Forms.cs

示例9: BeginSection

public static System.Web.WebPages.HelperResult BeginSection(IHtmlString title, IHtmlString leadingHtml, HtmlAttributes htmlAttributes) {
#line default
#line hidden
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {

#line 14 "..\..\Templates\HtmlHelpers.cshtml"
                                                                                                 


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "    <fieldset");


#line 15 "..\..\Templates\HtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, htmlAttributes);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, ">\r\n");

WriteLiteralTo(__razor_helper_writer, "        <legend>");


#line 16 "..\..\Templates\HtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, title);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "</legend>\r\n");

WriteLiteralTo(__razor_helper_writer, "        ");


#line 17 "..\..\Templates\HtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, leadingHtml);


#line default
#line hidden
WriteLiteralTo(__razor_helper_writer, "\r\n");

WriteLiteralTo(__razor_helper_writer, "        <dl>\r\n");


#line 19 "..\..\Templates\HtmlHelpers.cshtml"


#line default
#line hidden
});

#line 19 "..\..\Templates\HtmlHelpers.cshtml"
}
开发者ID:Royce,项目名称:ChameleonForms,代码行数:56,代码来源:HtmlHelpers.generated.cs

示例10: ActionLink

 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper,
                                        IHtmlString linkText,
                                        string actionName,
                                        string controllerName,
                                        RouteValueDictionary routeValues,
                                        IDictionary<string, Object> htmlAttributes)
 {
     var linkString = htmlHelper.ActionLink(guid, actionName, controllerName, routeValues, htmlAttributes);
     return ReplaceGuidWithRealText(linkText.ToString(), linkString);
 }
开发者ID:JWroe,项目名称:HelperLibrary,代码行数:10,代码来源:HtmlExtensions.cs

示例11: RenderSection

        public HelperResult RenderSection(string name, IHtmlString defaultContents)
        {
            if (this.IsSectionDefined(name))
            {
                return this.RenderSection(name);
            }

            var result = new HelperResult((x) => x.Write(defaultContents.ToString()));
            return this.RenderSection(name, (x) => result);
        }
开发者ID:nwvdnug,项目名称:NWVDNUGsite,代码行数:10,代码来源:CustomWebViewPage.cs

示例12: Create

 /// <summary>
 /// ����һ��MvcHtmlWrapper�������MvcHtmlWrapper��ֱ�ӷ��أ�
 /// �������������������MvcHtmlWrapper�󷵻�
 /// </summary>
 /// <param name="str">IHtmlString���ͣ�ʵ����ToHtmlString�ӿڵ�����</param>
 /// <returns></returns>
 public static MvcHtmlWrapper Create(IHtmlString str)
 {
     Contract.Requires(str != null);
     if (str is MvcHtmlWrapper)
         return str as MvcHtmlWrapper;
     if (str is MvcHtmlString)
         return new MvcHtmlWrapper(str);
     Contract.Assert(false);
     return null;
 }
开发者ID:uwitec,项目名称:mb-oa,代码行数:16,代码来源:MvcHtmlWrapper.cs

示例13: FlowFormMessage

        public FlowFormMessage(TextWriter writer, MessageType messageType, string heading, IHtmlString message = null)
        {
            _writer = writer;
            _writer.Write(HelperDefinitions.BeginMessage(messageType.ToDescription(), heading).ToHtmlString());

            if (message != null)
            {
                _writer.Write(message.ToHtmlString());
                _writer.Write(HelperDefinitions.EndMessage().ToHtmlString());
            }
        }
开发者ID:SharePointSusan,项目名称:Research-Data-Manager,代码行数:11,代码来源:FlowFormMessage.cs

示例14: ConfigName

		public void ConfigName(IHtmlString name) {
			this.FieldNamePrefix = name.ToString();

			if (String.IsNullOrEmpty(this.FieldNamePrefix)) {
				this.FieldNamePrefix = String.Empty;
			} else {
				this.FieldNamePrefix = String.Format("{0}.", this.FieldNamePrefix);
			}

			this.FieldIdPrefix = this.FieldNamePrefix.Replace(".", "_").Replace("]", "_").Replace("[", "_");
		}
开发者ID:ithanshui,项目名称:CarrotCakeCMS-MVC,代码行数:11,代码来源:CarrotWebGridBase.cs

示例15: DemoRow

		public static IHtmlString DemoRow(this HtmlHelper htmlHelper, string title, IHtmlString body, string title2 = null, IHtmlString body2 = null)
		{
			bool hasSecondCol = !title2.IsNullOrWhiteSpace();
			var colClass = hasSecondCol ? "col-sm-6" : "col-xs-12";

			string rowFormat = @"<div class=""row demoRow"">
										<div class=""{2} demoCol"">{0}</div>
										<div class=""{2} demoCol"">{1}</div>
									</div>";
			return htmlHelper.Raw(string.Format(rowFormat, htmlHelper.DemoPanel(title, body), hasSecondCol ? htmlHelper.DemoPanel(title2, body2) : new HtmlString(""), colClass));
		}
开发者ID:samdyao,项目名称:WebFrontEndDev,代码行数:11,代码来源:AWHtmlHelper.cs


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