public static IHtmlString StripHtml(this IHtmlString value)
        {
            const string pattern = @"<(.|\n)*?>";
            var          result  = new HtmlString(Regex.Replace(value.ToString(), pattern, string.Empty));

            return(result);
        }
示例#2
0
        public static IHtmlString ConvertImgToSrcSet(this HtmlHelper htmlHelper, IHtmlString html, bool generateLqip = true, bool removeStyleAttribute = false, bool removeUdiAttribute = false)
        {
            CheckObsoleteMethodUsageAndLog();
            var htmlString = html.ToString();

            return(ConvertImgToSrcSetInternal(htmlHelper, htmlString, generateLqip, removeStyleAttribute, removeUdiAttribute));
        }
示例#3
0
        /// <summary>
        /// Constructs a modal and an ajax handler for passing data from a partial in a modal to a controller action.
        /// This method is most useful when you're trying to do data validation with a partial view inside of a modal.
        /// By default forms will attempt to redirect to a returned action result which will close the modal. This
        /// modal prevents the form from navigating away while using ajax to speak with the controller asynchronously. That
        /// way if a partial validation is returned it can be reinserted into the modal without disorienting users.
        /// </summary>
        /// <param name="modalId">Your modals id.</param>
        /// <param name="titleText">The title display of the modal.</param>
        /// <param name="partialTargetId">The id of the innermost div for partial pages.</param>
        /// <param name="formId">The id of the form to submit. This lets the form button exist outside of the form.</param>
        /// <returns>An html string of the modal.</returns>
        public static IHtmlString ModalPreventDefault(string modalId, string titleText, string partialTargetId, string formId, ModalButtonType type = ModalButtonType.Submit)
        {
            //0 is modalId, 1 is formId ,2 is ajax
            string script   = "<script type='text/javascript'>{0}</script>";
            string function = " $('#{0}').on('submit',function(e){{e.preventDefault(); {1}{2}{3}{4} }});";

            string action = "var action = $('#{0}').attr('action');"; // 0 is formId
            string method = "var method = $('#{0}').attr('method');";
            string form   = "var form = $('#{0}');";                  // 0 is formid

            string ajaxCall = "$.ajax({{ url: action, type: method, data: form.serialize(), success: function(response)" +
                              "{{ $('#{0}').html(response);}} }});";

            //build action
            action   = String.Format(action, formId);
            method   = String.Format(method, formId);
            ajaxCall = String.Format(ajaxCall, partialTargetId);
            form     = String.Format(form, formId);

            function = String.Format(function, modalId, action, method, form, ajaxCall);

            script = String.Format(script, function);

            IHtmlString modal = Modal(modalId, titleText, partialTargetId, formId, type);

            string modalWithJS = String.Format("{0}{1}", modal.ToString(), script);

            return(new HtmlString(modalWithJS));
        }
示例#4
0
 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());
 }
        public static IHtmlString GetFirstParagraph(this IHtmlString value)
        {
            var match  = Regex.Match(value.ToString(), @"<p>\s*(.+?)\s*</p>");
            var result = new HtmlString(match.Success ? match.Groups[1].Value : string.Empty);

            return(result);
        }
示例#6
0
        /// <summary>
        /// Strips out &lt;p&gt; and &lt;/p&gt; tags if they were used as a wrapper
        /// for other HTML content.
        /// </summary>
        /// <param name="Text">The HTML text.</param>
        /// <param name="ConvertEmptyParagraphsToBreaks"></param>
        public static IHtmlString RemoveParagraphWrapperTags(this IHtmlString Text, bool ConvertEmptyParagraphsToBreaks = false)
        {
            var str       = Text.ToString();
            var fixedText = str.RemoveParagraphWrapperTags(ConvertEmptyParagraphsToBreaks);

            return(new HtmlString(fixedText));
        }
示例#7
0
        private static IHtmlString BuildCharacterWatcher <TModel, TProperty>(
            IHtmlString methodResult,
            Expression <Func <TModel, TProperty> > expression,
            string targetIdentifier)
        {
            var memberExpression = expression.Body as MemberExpression;

            if (memberExpression == null)
            {
                return(methodResult);
            }

            var propertyInfo = (PropertyInfo)memberExpression.Member;
            var attribute    = propertyInfo.GetCustomAttribute <StringLengthAttribute>();

            if (attribute == null || attribute.MaximumLength <= 5)
            {
                return(methodResult);
            }

            var watchId = Guid.NewGuid().ToString();

            var tag1 = new TagBuilder("span");

            tag1.Attributes.Add("class", "text-content-max-length-countdown");
            tag1.Attributes.Add("id", watchId);

            var tag2 = new TagBuilder("script");

            tag2.Attributes.Add("type", "text/javascript");
            tag2.InnerHtml =
                $"$(function(){{initCountdownWatcher('[{targetIdentifier}]', '#{watchId}', {attribute.MaximumLength});}});";

            return(new HtmlString(methodResult.ToString() + tag1 + tag2));
        }
示例#8
0
        public virtual string GetEditable(Context context, string key, EditableOptions options)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }
            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            IHtmlString html = null;

            context.Stack(() =>
            {
                html = Html.SnippetInternal(
                    key,
                    options.Type ?? "html",
                    options.Escape.GetValueOrDefault(false),
                    options.Tag ?? "div",
                    options.CssClass,
                    options.Liquid.GetValueOrDefault(true),
                    context,
                    options.Default);
            });

            return(html == null ? null : html.ToString());
        }
示例#9
0
 public static TagBuilder AppendHtml(this TagBuilder source, IHtmlString html)
 {
     if (html == null)
     {
         return(source);
     }
     return(AppendHtml(source, html.ToString()));
 }
 /// <summary>
 ///     Sets an attribute on this tag
 /// </summary>
 /// <param name="this">This tagbuilder</param>
 /// <param name="attribute"></param>
 /// <param name="html"></param>
 /// <param name="replaceExisting">
 ///     A value indicating whether the value should override the existing value should there be
 ///     one.
 /// </param>
 /// <returns>This tagbuilder</returns>
 public static TagBuilder Attribute(
     this TagBuilder @this,
     string attribute,
     IHtmlString html,
     bool replaceExisting = false)
 {
     return(Attribute(@this, attribute, html.ToString(), replaceExisting));
 }
示例#11
0
        public void Is(string expected, IHtmlString result, string message = null)
        {
            //var resultStr = result.ToString();
            //int index = expected.Zip(resultStr, (c1, c2) => c1 == c2).TakeWhile(b => b).Count() + 1;

            //Assert.AreEqual(expected, resultStr, message + $"(pos: {index}");
            Is(expected, result.ToString(), message);
        }
示例#12
0
        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()));
        }
        public void IsSelfClosing_ShouldBeFalse_ByDefault()
        {
            IHtmlString tagHtml1 = SimpleTag.Tag("div");
            IHtmlString tagHtml2 = SimpleTag.Tag("div", new {});

            Assert.True(tagHtml1.ToString().Contains("</div>"));
            Assert.True(tagHtml2.ToString().Contains("</div>"));
        }
示例#14
0
 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, IHtmlString linkText, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes)
 {
     if (String.IsNullOrEmpty(linkText.ToString()))
     {
         throw new ArgumentException("Argument must be a non empty string", "linkText");
     }
     return(MvcHtmlString.Create(GenerateLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, null /* routeName */, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes)));
 }
        public void ShouldBeAbleToSet_IsSelfClosing()
        {
            IHtmlString tagHtml1 = SimpleTag.Tag("input", true);
            IHtmlString tagHtml2 = SimpleTag.Tag("input", new { type = "text" }, true);

            Assert.True(tagHtml1.ToString().Contains(" />"));
            Assert.True(tagHtml2.ToString().Contains(" />"));
        }
示例#16
0
 public static IHtmlString FourElements(this HtmlHelper helper, IHtmlString left, IHtmlString middleLeft, IHtmlString middleRight, IHtmlString right)
 {
     return(new HtmlString(LayoutWork.ChildrenTemplate("childrenQuarter",
                                                       left.ToString(),
                                                       middleLeft.ToString(),
                                                       middleLeft.ToString(),
                                                       right.ToString())));
 }
示例#17
0
 public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, IHtmlString linkText, string routeName, RouteValueDictionary routeValues, IDictionary <string, object> htmlAttributes)
 {
     if (String.IsNullOrEmpty(linkText.ToString()))
     {
         throw new ArgumentException("Argument must be a non empty string", "linkText");
     }
     return(MvcHtmlString.Create(GenerateRouteLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, routeName, routeValues, htmlAttributes)));
 }
示例#18
0
 /// <summary>
 ///   Parses multiple <see cref="HtmlTag" />s from the given <paramref name="html" />
 /// </summary>
 /// <param name="html">The html</param>
 /// <param name="validateSyntax">A value indicating whether the html should be checked for syntax errors.</param>
 /// <returns>A collection of <see cref="HtmlTag" /></returns>
 /// <exception cref="InvalidOperationException">
 ///   If <paramref name="validateSyntax" /> is true and syntax errors are
 ///   encountered in the <paramref name="html" />
 /// </exception>
 public static IEnumerable <HtmlTag> ParseAll(IHtmlString html, bool validateSyntax = false)
 {
     if (html == null)
     {
         throw new ArgumentNullException("html");
     }
     return(ParseAll(html.ToString(), validateSyntax));
 }
        /// <summary>
        /// Determines whether [is null or whitespace] [the specified HTML].
        /// </summary>
        /// <param name="html">The HTML.</param>
        /// <returns></returns>
        public static bool IsNullOrWhiteSpace(this IHtmlString html)
        {
            if (html == null)
            {
                return(true);
            }

            return(string.IsNullOrWhiteSpace(html.ToString()));
        }
        /// <summary>
        /// Removes the first surrounding tag of the HTML string.
        /// </summary>
        /// <param name="html">HTML string</param>
        /// <param name="tag">Name of the tag to remove (e.g. "p")</param>
        /// <returns></returns>
        public static IHtmlString RemoveSurroundingTag(this IHtmlString html, string tag)
        {
            if (html == null)
            {
                return(html);
            }

            return(new HtmlString(html.ToString().TrimStart($"<{tag}>").TrimEnd($"</{tag}>")));
        }
示例#21
0
        private static Tuple <IHtmlString, string> MarkTarget(this IHtmlString generatedHtmlTag)
        {
            var targetIdentifier = Guid.NewGuid().ToString();
            var tagString        = generatedHtmlTag.ToString();
            var markedString     = tagString.Insert(tagString.IndexOf(" ", StringComparison.CurrentCulture), $" {targetIdentifier} ");
            var markedTag        = new HtmlString(markedString);

            return(new Tuple <IHtmlString, string>(markedTag, targetIdentifier));
        }
示例#22
0
        public IHtmlString Draw(IEnumerable <WebGridColumn> columns)
        {
            // prepare data table HTML
            IHtmlString ret = this.Table(columns: columns,
                                         tableStyle: "table table-hover");
            string alert = "";

            if (this.Rows.Count == 0)
            {
                alert = "<div class='alert alert-danger alert-sm'>No record found...</div>";
            }
            else if (this.TotalRowCount == take)
            {
                alert = "<div class='alert alert-warning alert-sm'>There are more than " +
                        take.ToString() + " records, use search filter to limit returned records.</div>";
            }

            Regex         e    = new Regex("<thead>.*<\\/thead>", RegexOptions.Singleline);
            StringBuilder sbth = new StringBuilder();

            sbth.AppendLine("<thead>");
            sbth.AppendLine("<tr>");
            foreach (var i in columns)
            {
                sbth.AppendFormat("<td scope=\"col\" class=\"{1}\">{0}</td>",
                                  HttpUtility.HtmlEncode(i.Header),
                                  i.Style);
            }
            sbth.AppendLine("</tr>");
            sbth.AppendLine("</thead>");
            string strret = e.Replace(ret.ToString(), sbth.ToString());

            //replace paginator look and feel
            string _paginator = " " + this.Pager(
                firstText: "<<",
                previousText: "<",
                nextText: ">",
                lastText: ">>",
                mode: WebGridPagerModes.All
                ).ToHtmlString().Replace("<a href=", "<li><a href=").Replace("</a>", "</a></li>") + " ";
            int _idx = this.PageIndex + 1;

            _paginator = _paginator.Replace(" " + _idx.ToString() + " ", "<li class='active'><a>" + _idx.ToString() + "</a></li>");

            _paginator =
                "<nav><ul class='pagination pagination-small'>"
                + _paginator
                + "</ul></nav>";

            if (noPag)
            {
                _paginator = "";
            }

            //return new HTML code decorated by alert and paginator
            return(new HtmlString(alert + strret + _paginator));
        }
示例#23
0
        /// <summary>
        /// Renders a a Snippet (adx_contentsnippet) value, with no encoding or other modification.
        /// </summary>
        /// <param name="html">Extension method target, provides support for HTML rendering and access to view context/data.</param>
        /// <param name="snippetName">The name (adx_name) of the Snippet (adx_contentsnippet) to be rendered.</param>
        /// <param name="defaultValue">An optional default value to be returned if the snippet does not exist or has no value.</param>
        /// <returns>
        /// A literal content snippet value, or <paramref name="defaultValue"/>, if the snippet is not found or has no value. If
        /// <paramref name="defaultValue"/> is also null, returns an empty string.
        /// </returns>
        public static string SnippetLiteral(this HtmlHelper html, string snippetName, IHtmlString defaultValue, bool liquidEnabled = LiquidExtensions.LiquidEnabledDefault)
        {
            var snippet = PortalExtensions.GetPortalViewContext(html).Snippets.Select(snippetName);

            if (snippet != null)
            {
                return(SnippetLiteral(html, snippet, defaultValue == null ? null : defaultValue.ToString(), liquidEnabled));
            }

            if (defaultValue == null)
            {
                return(null);
            }

            return(liquidEnabled
                                ? html.Liquid(defaultValue)
                                : defaultValue.ToString());
        }
示例#24
0
        public static IHtmlString AddRouteValuesToWebGridHeaders(this IHtmlString grid, string routeValues)
        {
            var regularString = grid.ToString();

            regularString = regularString.Replace("?sort=", "?" + routeValues + "&sort=");

            HtmlString htmlString = new HtmlString(regularString);

            return(htmlString);
        }
示例#25
0
 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);
 }
示例#26
0
    public override void WriteJson(Newtonsoft.Json.JsonWriter writer, object value, Newtonsoft.Json.JsonSerializer serializer)
    {
        IHtmlString source = value as IHtmlString;

        if (source == null)
        {
            return;
        }
        writer.WriteValue(source.ToString());
    }
示例#27
0
        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);
        }
示例#28
0
        public IHtmlString Draw(IEnumerable <WebGridColumn> columns)
        {
            // prepare data table HTML
            IHtmlString ret = this.Table(columns: columns,
                                         tableStyle: "table table-hover");
            string alert = "";

            if (this.Rows.Count == 0)
            {
                alert = "<div class='alert alert-danger alert-sm'>No record found...</div>";
            }
            else if (this.TotalRowCount == take)
            {
                alert = "<div class='alert alert-warning alert-sm'>There are more than " +
                        take.ToString() + " records, use search filter to limit returned records.</div>";
            }

            Regex         e    = new Regex("<thead>.*<\\/thead>", RegexOptions.Singleline);
            StringBuilder sbth = new StringBuilder();

            sbth.AppendLine("<thead>");
            sbth.AppendLine("<tr>");
            foreach (var i in columns)
            {
                sbth.AppendFormat("<td scope=\"col\" class=\"{1}\">{0}</td>",
                                  HttpUtility.HtmlEncode(i.Header),
                                  i.Style);
            }
            sbth.AppendLine("</tr>");
            sbth.AppendLine("</thead>");
            string strret = e.Replace(ret.ToString(), sbth.ToString());

            //replace paginator look and feel
            var _sbPag = new StringBuilder();

            foreach (var p in pageNavItems)
            {
                if (p.PageId == CurrPageId)
                {
                    _sbPag.AppendFormat("<li class='active'><a>{0}</a></li>", p.ToMyString());
                }
                else
                {
                    _sbPag.AppendFormat("<li><a href='{1}{2}'>{0}</a></li>",
                                        p.ToMyString(), this.GetPageUrl(0).Replace("page=1", "page="), p.PageId);
                }
            }
            string _paginator =
                "<nav><ul class='pagination pagination-small'>"
                + _sbPag.ToString()
                + "</ul></nav>";

            //return new HTML code decorated by alert and paginator
            return(new HtmlString(alert + strret + _paginator));
        }
示例#29
0
        public static IHtmlString Restrict(this HtmlHelper htmlHeper, UserSessionObject currentUser, string neededPermission, IHtmlString content)
        {
            MvcHtmlString mvcHtmlString = null;

            if (currentUser.Permissions.Contains(neededPermission))
            {
                mvcHtmlString = new MvcHtmlString(content.ToString());
            }

            return(mvcHtmlString);
        }
        public void ShouldBeAbleToDefine_CusomHtmlAttributes()
        {
            IHtmlString tagHtml1 = SimpleTag.Tag("input", new { type = "submit", value = "GO!" }, true);
            IHtmlString tagHtml2 = SimpleTag.Tag("input", new { type = "text", disabled = "disabled" }, true);

            string expected1 = "<input type=\"submit\" value=\"GO!\" />";
            string expected2 = "<input type=\"text\" disabled=\"disabled\" />";

            Assert.Equal(expected1, tagHtml1.ToString());
            Assert.Equal(expected2, tagHtml2.ToString());
        }
		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("[", "_");
		}
示例#32
0
        public static IHtmlString CampaignUrl(this UrlHelper urlHelper,
                                              IHtmlString url,
                                              string campaign)
        {
            var s = url.ToString();

            if (s.Contains("?"))
            {
                return(new MvcHtmlString(s + "&utm_campaign=" + HttpContext.Current.Server.UrlEncode(campaign)));
            }
            return(new MvcHtmlString(s + "?utm_campaign=" + HttpContext.Current.Server.UrlEncode(campaign)));
        }
        public void RawAllowsNullObjectValue()
        {
            // Arrange
            HtmlHelper htmlHelper = HtmlHelperFactory.Create();

            // Act
            IHtmlString markupHtml = htmlHelper.Raw((object)null);

            // Assert
            Assert.Null(markupHtml.ToString());
            Assert.Null(markupHtml.ToHtmlString());
        }
        public void RawAllowsEmptyValue()
        {
            // Arrange
            HtmlHelper htmlHelper = HtmlHelperFactory.Create();

            // Act
            IHtmlString markupHtml = htmlHelper.Raw("");

            // Assert
            Assert.Equal("", markupHtml.ToString());
            Assert.Equal("", markupHtml.ToHtmlString());
        }
示例#35
0
 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper,
                                        IHtmlString linkText,
                                        string actionName,
                                        string controllerName,
                                        string protocol,
                                        string hostName,
                                        string fragment,
                                        Object routeValues,
                                        Object htmlAttributes)
 {
     var linkString = htmlHelper.ActionLink(guid, actionName, controllerName, protocol, hostName, fragment, routeValues, htmlAttributes);
     return ReplaceGuidWithRealText(linkText.ToString(), linkString);
 }
示例#36
0
 public static IHtmlString Concat(this IHtmlString firstString, IHtmlString secondString)
 {
     return new HtmlString(firstString.ToString() + "\r\n" + secondString.ToString());
 }
public static System.Web.WebPages.HelperResult BeginNestedSection(IHtmlString heading, IHtmlString leadingHtml, HtmlAttributes htmlAttributes)
{
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {



#line 29 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
 
    htmlAttributes.AddClass("panel panel-default");

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "    <div");



#line 31 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, htmlAttributes);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, ">\r\n");



#line 32 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "        <div class=\"panel-heading\">");



#line 34 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, heading);

#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "</div>\r\n");



#line 35 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    }


#line default
#line hidden

WebViewPage.WriteLiteralTo(@__razor_helper_writer, "        <div class=\"panel-body\">\r\n");



#line 38 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {
        
#line default
#line hidden


#line 40 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
WebViewPage.WriteTo(@__razor_helper_writer, leadingHtml);

#line default
#line hidden


#line 40 "..\..\Templates\TwitterBootstrap3\TwitterBootstrapHtmlHelpers.cshtml"
                    
    }

#line default
#line hidden

});

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

#line 27 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
 
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {


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


#line 30 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, heading);


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


#line 31 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


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


#line 33 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {


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


#line 35 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, leadingHtml);


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


#line 36 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


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


#line 37 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, htmlAttributes);


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


#line 38 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"


#line default
#line hidden
});

#line 38 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
}
示例#39
0
 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, IHtmlString linkText, string actionName, Object routeValues, Object htmlAttributes)
 {
     var linkString = htmlHelper.ActionLink(guid, actionName, routeValues, htmlAttributes);
     return ReplaceGuidWithRealText(linkText.ToString(), linkString);
 }
示例#40
0
 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, IHtmlString linkText, string actionName, string controllerName)
 {
     var linkString = htmlHelper.ActionLink(guid, actionName, controllerName);
     return ReplaceGuidWithRealText(linkText.ToString(), linkString);
 }
示例#41
0
 public static TagBuilder AppendHtml(this TagBuilder source, IHtmlString html)
 {
     if (html == null)
     {
         return source;
     }
     return AppendHtml(source, html.ToString());
 }
示例#42
0
 public static void AreEqual(IHtmlString expected, IHtmlString actual)
 {
     HtmlAssert.AreEqual(expected.ToString(), actual.ToString());
 }
示例#43
0
 public static TagBuilder PrependHtml(this TagBuilder source, IHtmlString html)
 {
     return PrependHtml(source, html.ToString());
 }
示例#44
0
 private static string GenerateLinkInternal(RequestContext requestContext, RouteCollection routeCollection, IHtmlString linkText, string routeName, string actionName, string controllerName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes, bool includeImplicitMvcValues) {
     string url = UrlHelper.GenerateUrl(routeName, actionName, controllerName, protocol, hostName, fragment, routeValues, routeCollection, requestContext, includeImplicitMvcValues);
     TagBuilder tagBuilder = new TagBuilder("a") {
         InnerHtml = linkText.ToString()
     };
     tagBuilder.MergeAttributes(htmlAttributes);
     tagBuilder.MergeAttribute("href", url);
     return tagBuilder.ToString(TagRenderMode.Normal);
 }
示例#45
0
 /// <summary>
 /// Enables rich text on a given input text.
 /// </summary>
 /// <param name="input">Input text.</param>
 /// <returns>Rich text.</returns>
 public static IHtmlString Enable(IHtmlString input)
 {
     return Enable(input != null ? input.ToString() : string.Empty);
 }
public static System.Web.WebPages.HelperResult BeginSection(IHtmlString heading, IHtmlString leadingHtml, HtmlAttributes htmlAttributes) {
#line default
#line hidden
return new System.Web.WebPages.HelperResult(__razor_helper_writer => {

#line 13 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
                                                                                                   


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


#line 14 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, htmlAttributes);


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


#line 15 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    if (heading != null && !string.IsNullOrWhiteSpace(heading.ToString()))
    {


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


#line 17 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, heading);


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


#line 18 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }
    if (leadingHtml != null && !string.IsNullOrWhiteSpace(leadingHtml.ToString()))
    {


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


#line 21 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
WriteTo(__razor_helper_writer, leadingHtml);


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


#line 22 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
    }


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


#line 24 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"


#line default
#line hidden
});

#line 24 "..\..\Templates\Default\DefaultHtmlHelpers.cshtml"
}
示例#47
0
 public static MvcHtmlString RouteLink(this HtmlHelper htmlHelper, IHtmlString linkText, string routeName, string protocol, string hostName, string fragment, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {
     if (String.IsNullOrEmpty(linkText.ToString())) {
         throw new ArgumentException("Argument must be a non empty string", "linkText");
     }
     return MvcHtmlString.Create(GenerateRouteLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, routeName, protocol, hostName, fragment, routeValues, htmlAttributes));
 }
示例#48
0
 public static MvcHtmlString ActionLink(this HtmlHelper htmlHelper, IHtmlString linkText, string actionName, string controllerName, RouteValueDictionary routeValues, IDictionary<string, object> htmlAttributes) {
     if (String.IsNullOrEmpty(linkText.ToString())) {
         throw new ArgumentException("Argument must be a non empty string", "linkText");
     }
     return MvcHtmlString.Create(GenerateLink(htmlHelper.ViewContext.RequestContext, htmlHelper.RouteCollection, linkText, null /* routeName */, actionName, controllerName, routeValues, htmlAttributes));
 }
示例#49
0
 private void AssertEqualsIgnoreLineBreaks(string expected, IHtmlString actual) {
     Assert.AreEqual(expected, actual.ToString().Replace("\r\n", ""));
 }