public static object Json(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper html, object obj) { string str = JsonConvert.SerializeObject(obj); if (!string.IsNullOrEmpty(str)) { str = Regex.Replace(str, @"<(/?script[\s>])", "<\"+\"$1", RegexOptions.IgnoreCase); } if (html == null) { return(str); } return(html.Raw(str)); }
public static HtmlString AppSourceFile(this HtmlHelper helper, string file) { var location = ((RazorView)helper.ViewContext.View).Path; var path = Path.GetDirectoryName(location.Replace("/", "\\")); path = System.IO.Path.Combine(path, file); return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode(path.Replace("\\", "/").Replace("~/", // using syntax below to prevent replace of S E R E N E in URL "https://github.com/volkanceylan/S" + "erene/blob/master/S" + "erene/S" + "erene.Web/")) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }
public static string GetLocalTextInclude(this HtmlHelper page, string package) { string languageId = CultureInfo.CurrentUICulture.Name.TrimToNull() ?? "invariant"; var context = Dependency.TryResolve <ILocalTextContext>(); var isPending = context != null && context.IsApprovalMode; string scriptName = LocalTextScript.GetScriptName(package, languageId, isPending); DynamicScriptManager.IfNotRegistered(scriptName, () => { var script = new LocalTextScript(package, (string)languageId, isPending); DynamicScriptManager.Register(script); }); return(DynamicScriptManager.GetScriptInclude(scriptName)); }
/// <summary> /// Determines whether the specified controller is selected. /// </summary> /// <param name="html">The HTML.</param> /// <param name="controller">The controller.</param> /// <param name="action">The action.</param> /// <param name="cssClass">The CSS class.</param> /// <returns></returns> public static string IsSelected(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper html, string controller = null, string action = null, string cssClass = "selected") { // const string cssClass = "selected"; var currentAction = (string)html.ViewContext.RouteData.Values["action"]; var currentController = (string)html.ViewContext.RouteData.Values["controller"]; if (String.IsNullOrEmpty(controller)) { controller = currentController; } if (String.IsNullOrEmpty(action)) { action = currentAction; } return(controller == currentController && action == currentAction ? cssClass : String.Empty); }
public static HtmlString AppSourceFile(this HtmlHelper helper, string file) { var viewLocation = ((RazorView)helper.ViewContext.View).Path; var absolutePath = Path.GetDirectoryName(viewLocation).Replace('\\', '/') + '/'; var relative = file.Replace('\\', '/'); var question = relative.IndexOf('?'); if (question >= 0) { relative = new Uri("x:" + absolutePath + relative.Substring(0, question)) .AbsolutePath.Substring(2) + relative.Substring(question); } else { relative = new Uri("x:" + absolutePath + relative).AbsolutePath.Substring(2); } return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode("https://github.com/volkanceylan/S" + "erene/blob/master/S" + "erene/S" + "erene.Web" + relative) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }
public static HtmlString BasicSamplesSourceFile(this HtmlHelper helper, string file) { var viewLocation = ((RazorView)helper.ViewContext.View).Path; var absolutePath = Path.GetDirectoryName(viewLocation).Replace('\\', '/') + '/'; var relative = file.Replace('\\', '/'); var question = relative.IndexOf('?', StringComparison.Ordinal); if (question >= 0) { relative = new Uri("x:" + absolutePath + relative.Substring(0, question)) .AbsolutePath.Substring(2) + relative.Substring(question); } else { relative = new Uri("x:" + absolutePath + relative).AbsolutePath.Substring(2); } return(new HtmlString("<a target=\"blank\" style=\"font-weight: bold; color: #ffc\" href=\"" + helper.Encode("https://github.com/serenity-is/common-features/" + "blob/master/src/Serenity.Demo.BasicSamples/" + relative) + "\">" + helper.Encode(Path.GetFileName(file)) + "</a>")); }
public static System.Threading.Tasks.Task <Microsoft.AspNetCore.Html.IHtmlContent> RenderComponentAsync <TComponent>(this Microsoft.AspNetCore.Mvc.Rendering.IHtmlHelper htmlHelper) where TComponent : Microsoft.AspNetCore.Components.IComponent { throw null; }
///<summary> /// Displays a configurable "Go To Page:" form for instances of PagedList. ///</summary> ///<param name="html">This method is meant to hook off HtmlHelper as an extension method.</param> ///<param name="list">The PagedList to use as the data source.</param> ///<param name="formAction">The URL this form should submit the GET request to.</param> ///<returns>Outputs the "Go To Page:" form HTML.</returns> public static HtmlString PagedListGoToPageForm(this IHtmlHelper html, IPagedList list, string formAction) { return(PagedListGoToPageForm(html, list, formAction, "page")); }
///<summary> /// Displays a configurable paging control for instances of PagedList. ///</summary> ///<param name = "html">This method is meant to hook off HtmlHelper as an extension method.</param> ///<param name = "list">The PagedList to use as the data source.</param> ///<param name = "generatePageUrl">A function that takes the page number of the desired page and returns a URL-string that will load that page.</param> ///<returns>Outputs the paging control HTML.</returns> public static HtmlString PagedListPager(this IHtmlHelper html, IPagedList list, Func <int, string> generatePageUrl) { return(PagedListPager(html, list, generatePageUrl, new PagedListRenderOptions())); }
/// <summary> /// Creates one <see cref="MultiColumnComboBox{T}" /> instance. /// </summary> /// <param name="helper">The html helper</param> /// <param name="selector">The selector</param> public MultiColumnComboBox(HtmlHelper helper, string selector = null) : base(helper, selector) { Initialize(); }
public static HtmlString Stylesheet(this HtmlHelper helper, string cssUrl) { return(new HtmlString(string.Format(" <link href=\"{0}\" rel=\"stylesheet\" type=\"text/css\"/>\n", ContentHashCache.ResolveWithHash(cssUrl)))); }