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


C# Web.HtmlString类代码示例

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


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

示例1: Foo

 public static HtmlString Foo(this HtmlHelper h, string attr, string id, string tagElement)
 {
     var tBuilder = new TagBuilder(tagElement);
     tBuilder.GenerateId(attr + id);
     var c = new HtmlString(tBuilder.ToString());
     return c;
 }
开发者ID:kamaelyoung,项目名称:My-MVC-Blog,代码行数:7,代码来源:CommentHelperExtension.cs

示例2: OnLoad

		protected override void OnLoad(EventArgs e)
		{
			IsQuestion = Msg.Type == MsgType.Question;
			LeftTime.Visible = !IsQuestion;
			RightTime.Visible = IsQuestion;
			Text = new HtmlString(Msg.Text.HtmlEncode().ReplaceMatches(@"\r?\n", "<br/>"));
		}
开发者ID:Arsennikum,项目名称:qctf-starter-2015,代码行数:7,代码来源:ChatMessage.ascx.cs

示例3: agregarMultimedia

 public ActionResult agregarMultimedia(int id)
 {
     var Patrocinador = db.patrocinador.FirstOrDefault(e => e.idPatrocinador.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Patrocinador.fuenteGrafica));
     Patrocinador.fuenteGrafica = h.ToString();
     return View(Patrocinador);
 }
开发者ID:ruisu08,项目名称:Protos,代码行数:7,代码来源:PatrocinadorController.cs

示例4: PageLink

        public static IHtmlString PageLink(this IFrontHtmlHelper frontHtml, object linkText, string urlKey, object routeValues, object htmlAttributes)
        {
            var htmlValues = RouteValuesHelper.GetRouteValues(htmlAttributes);
            Page page;

            string url = frontHtml.Page_Context.FrontUrl.PageUrl(urlKey, routeValues, out page).ToString();

            var innerHtml = "";
            if (linkText == null)
            {
                innerHtml = page.GetLinkText();
            }
            else
            {
                innerHtml = HttpUtility.HtmlEncode(linkText);
            }
            TagBuilder builder = new TagBuilder("a")
            {
                InnerHtml = innerHtml
            };
            builder.MergeAttributes<string, object>(htmlValues);
            builder.MergeAttribute("href", url);
            //if (page != null && page.Route != null)
            //{
            //    builder.MergeAttribute("target", page.Route.LinkTarget.ToString());
            //}
            var html = new HtmlString(builder.ToString(TagRenderMode.Normal));

            #if Page_Trace
            stopwatch.Stop();
            HttpContext.Current.Response.Write(string.Format("PageLink,{0}.</br>", stopwatch.Elapsed));
            #endif
            return html;
        }
开发者ID:Kooboo,项目名称:Ovaldi,代码行数:34,代码来源:PageLinkExtensions.cs

示例5: RenderCSS

        public static HtmlString RenderCSS(HtmlString mediaQuery, params string[] fileNames)
        {
            StringBuilder stringBuilder = new StringBuilder();
            HttpContext context = HttpContext.Current;

            // Minify on release.
            if (!context.IsDebuggingEnabled)
            {
                string fileContent = AsyncHelper.RunSync(() => CssProcessor.ProcessCssCrunchAsync(context, true, fileNames));
                string fileName = $"{fileContent.ToMd5Fingerprint()}.css";
                return
                    new HtmlString(
                        string.Format(
                            CssPhysicalFileTemplate,
                            AsyncHelper.RunSync(
                                () => ResourceHelper.CreateResourcePhysicalFileAsync(fileName, fileContent)),
                            mediaQuery));
            }

            // Render them separately for debug mode.
            foreach (string name in fileNames)
            {
                string currentName = name;
                string fileContent = AsyncHelper.RunSync(() => CssProcessor.ProcessCssCrunchAsync(context, false, currentName));
                string fileName = $"{Path.GetFileNameWithoutExtension(name)}{fileContent.ToMd5Fingerprint()}.css";
                stringBuilder.AppendFormat(
                    CssPhysicalFileTemplate,
                    AsyncHelper.RunSync(() => ResourceHelper.CreateResourcePhysicalFileAsync(fileName, fileContent)),
                    mediaQuery);
                stringBuilder.AppendLine();
            }

            return new HtmlString(stringBuilder.ToString());
        }
开发者ID:JimBobSquarePants,项目名称:Cruncher,代码行数:34,代码来源:CruncherBundler.cs

示例6: RenderProfileThemes

        public static HtmlString RenderProfileThemes(this CDN e, int? userID)
        {
            const string settingid = "theme-link";
            var themeValue = "";

            if (HttpContext.Current.Session[settingid] == null && userID != null && userID != 0)
            {
                if (HttpContext.Current.Request.Cookies.AllKeys.Contains(settingid))
                {
                    var httpCookie = HttpContext.Current.Request.Cookies[settingid];
                    if (httpCookie != null)
                    {
                        var val = httpCookie.Value;
                        if (!string.IsNullOrWhiteSpace(val))
                        {
                            HttpContext.Current.Session[settingid] = val;
                            return e.RenderProfileThemes(userID);
                        }
                    }
                }

                using (var db = DAL.Instance.DefaultDbContext())
                {
                    var setting = db.UserProfiles.SingleOrDefault(s => s.UserId == userID && s.SettingId == (int)ProfileSetting.ThemeColor);
                    if (setting != null) HttpContext.Current.Session[settingid] = themeValue = setting.Value;
                }
            }
            else
                themeValue = (HttpContext.Current.Session[settingid] ?? e.DefaultThemeStyle).ToString();

            var returnString = new HtmlString(string.Format("<link id='theme-link' href='{0}' rel='stylesheet' />", string.IsNullOrEmpty(themeValue) ? e.DefaultThemeStyle : themeValue));
            return returnString;
        }
开发者ID:softrick-solution,项目名称:framework,代码行数:33,代码来源:HtmlHelperExtensions.cs

示例7: GetPageHtml

    public static string GetPageHtml(int total, int pageSize, int pageIndex)
    {
        int allpage = 0;//总页数
        int next = 0;//下一页
        int prev = 0;//上一页
        string pagestr = "";
        int startCount = 0;//开始页
        int endCount = 0;//结束页
        if (pageIndex < 1) { pageIndex = 1; }
        //计算总页数
        if (pageSize != 0)
        {
            allpage = (total / pageSize);
            allpage = ((total % pageSize) != 0 ? allpage + 1 : allpage);
            allpage = (allpage == 0 ? 1 : allpage);
        }
        next = pageIndex + 1;
        prev = pageIndex - 1;
        startCount = (pageIndex + 5) > allpage ? allpage - 9 : pageIndex - 4;//中间页起始序号
        endCount = pageIndex < 5 ? 10 : pageIndex + 5;
        if (startCount < 1) { startCount = 1; }
        if (allpage < endCount) { endCount = allpage; }
        pagestr += pageIndex > 1 ? "<a class=\"paginate_button\" href=\"javascript:$$.listSubmit(3,1)\">首页</a><a class=\"paginate_button\" href=\"javascript:$$.listSubmit(3," + prev + ")\">上一页</a>" : "";
        for (int i = startCount; i <= endCount; i++)
        {
            pagestr += pageIndex == i ? "<a id=\"current\">" + i + "</a>" : "<a class=\"paginate_button\" href=\"javascript:$$.listSubmit(3," + i + ")\">" + i + "</a>";
        }
        pagestr += pageIndex != allpage ? "<a class=\"paginate_button\" href=\"javascript:$$.listSubmit(3," + next + ")\">下一页</a><a class=\"paginate_button\" href=\"javascript:$$.listSubmit(3," + allpage + ")\">尾页</a>" : "";

        var selectHtml = "<select onchange=\"$$.listSubmit(2,this)\"><option " + (pageSize == 5 ? "selected=\"selected\"" : "") + " >5</option><option " + (pageSize == 10 ? "selected=\"selected\"" : "") + ">10</option><option " + (pageSize == 30 ? "selected=\"selected\"" : "") + ">30</option><option " + (pageSize == 50 ? "selected=\"selected\"" : "") + ">50</option><option " + (pageSize == 100 ? "selected=\"selected\"" : "") + ">100</option></select>";
        HtmlString result = new HtmlString("<div class=\"M_pagination\"><span>共" + total + "条记录" + selectHtml + "</span>" + pagestr + "</div>");
        return result.ToString();
    }
开发者ID:cameo29,项目名称:JQTable,代码行数:33,代码来源:Ajax.aspx.cs

示例8: Transform

 public static HtmlString Transform(this string htmlString, Action<CQ> transform)
 {
     var cq = CsQuery.CQ.Create(htmlString);
     transform(cq);
     var html = new HtmlString(cq.Render());
     return html;
 }
开发者ID:genoher,项目名称:Noodles,代码行数:7,代码来源:CqHelperExtensions.cs

示例9: agregarContenido

 public ActionResult agregarContenido(int id)
 {
     var Pagina = db.pagina_informativa.FirstOrDefault(e => e.idPagina_Informativa.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Pagina.contenido));
     Pagina.contenido = h.ToString();
     return View(Pagina);
 }
开发者ID:ruisu08,项目名称:Protos,代码行数:7,代码来源:PaginaInformativaController.cs

示例10: monitoringList

 /*hier worden de waardes die uit de functie getMonitoringFromMongo gesplitst.
 iedere waarde word dan in een div gezet.
 */
 public static async Task<HtmlString> monitoringList(List<string> rest, List<Int64> id, List<string> date)
 {
     var listBuilder = "";
     listBuilder += "<b><tr><td>Unit ID</td><td>Type</td><td>Max Begin</td><td>Min Begin</td><td>Max Eind</td><td>Min Eind</td></tr></b>";
     foreach (var unit in id)
     {
         var i = 0;
         while (rest.Count > i)
         {
             try {
                 var monitoring = await Task.Run(() => RaportMaker.getMonitoringFromMongo(date[1], date[2], unit, date[0] + " ", rest[i]));
                 var length = monitoring.Count - 1;
                 var min = monitoring[0]["Min"].ToString();
                 var max = monitoring[0]["Max"].ToString();
                 var minEnd = monitoring[length]["Min"].ToString();
                 var maxEnd = monitoring[length]["Max"].ToString();
                 listBuilder += "<tr><td>"+ unit + "</td><td>"+rest[i]+"</td><td>"+ max + "</td><td>" + max +"</td><td>"+ maxEnd +"</td><td>" + minEnd+"</td></tr>";
                 i++;
             }
             catch { i++; }
         }
     }
     listBuilder = "<div id='reportTable'><table>" + listBuilder + "</table></div>";
     var htmlResult = new HtmlString(listBuilder);
     return htmlResult;
 }
开发者ID:ChuckTenton,项目名称:CityGist-Project-56,代码行数:29,代码来源:RaportGenerator.cs

示例11: positionList

 public static async Task<HtmlString> positionList(List<Int64> id, List<string> date)
 {
     /*hier worden de waardes die uit de functie getCollectionFromMongo gesplitst.
 iedere waarde word omgezet via de position class.
 iedere omgezette waarde wordt dan in een aparte div gezet.
 */
     var listBuilder = "";
     foreach (var unit in id)
     {
         try {
             var position = await Task.Run(() => RaportMaker.getCollectionFromMongo(unit, date, "Position"));
             if (position[0] != null)
             {
                 var length = position.Count - 1;
                 var corx = position[0]["Rdx"].ToDouble();
                 var cory = position[0]["Rdy"].ToDouble();
                 var corxEnd = position[length]["Rdx"].ToDouble();
                 var coryEnd = position[length]["Rdy"].ToDouble();
                 IRijksdriehoekComponent convert = new Position();
                 var outcome = convert.ConvertToLatLong(corx, cory);
                 var outcomeEnd = convert.ConvertToLatLong(corxEnd, coryEnd);
                 listBuilder += "<div><h4> de begin coördinaten van:"+unit+" zijn: " + outcome + "</h4></div>";
                 listBuilder += "<div><h4> de eind coördinaten van:"+unit+" zijn: " + outcomeEnd + "</h4></div>";
             }
         }
         catch { }
     }
     var htmlResult = new HtmlString(listBuilder);
     return htmlResult;
 }
开发者ID:ChuckTenton,项目名称:CityGist-Project-56,代码行数:30,代码来源:RaportGenerator.cs

示例12: FormGroup

 public FormGroup(HtmlString input, HtmlString label, FormGroupType type, bool fieldIsValid = true)
 {
     _input = input;
     _label = label;
     _type = type;
     _fieldIsValid = fieldIsValid;
 }
开发者ID:andrewreyes,项目名称:NiftyMvcHelpers,代码行数:7,代码来源:FormGroup.cs

示例13: Icon

        /// <summary>
        /// Renders an icon image using the specified metadata.
        /// </summary>
        /// <param name="title">The title to use. If NULL, defaults to the value stored on the icon.</param>
        /// <param name="alt">The alt text. If NULL, defaults to the value stored on the icon.</param>
        /// <param name="url">A URL to link to. If not NULL, a link tag to this value is wrapped around the icon.</param>
        /// <param name="onclick">The onclick handler to render.</param>
        /// <param name="cssClass">The CSS class to assign to the image.</param>
        /// <param name="attributes">A dictionary of additional html attributes to render.</param>
        public static IHtmlString Icon(this HtmlHelper html,
			IIconMetaData icon,
			string title = null,
			string alt = null,
			string url = null,
			string onclick = null,
			string cssClass = null,
			object attributes = null)
        {
            var image = new TagBuilder("img");
            image.Attributes.Add("alt", alt ?? icon.AltText);
            image.Attributes.Add("title", title ?? icon.Title);

            SetOnclickHandler(onclick, image);
            SetCssClass(cssClass, image);
            SetImageSrc(html, icon, image);
            MergeHtmlAttributes(attributes, image);

            var imageTagHtml = new HtmlString(
                image.ToString(TagRenderMode.SelfClosing)
            );

            if (url.IsNotNullOrEmpty()) {
                imageTagHtml = new HtmlString(
                    String.Format("<a href=\"{0}\">{1}</a>", url, imageTagHtml.ToString())
                );
            }

            return imageTagHtml;
        }
开发者ID:spetryjohnson,项目名称:IconHelper,代码行数:39,代码来源:IconExtensions.cs

示例14: agregarMultimedia

 public ActionResult agregarMultimedia(int id)
 {
     var Anuncio = db.anuncio.FirstOrDefault(e => e.idAnuncio.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Anuncio.fuenteGrafica));
     Anuncio.fuenteGrafica = h.ToString();
     return View(Anuncio);
 }
开发者ID:ruisu08,项目名称:Protos,代码行数:7,代码来源:AnuncioController.cs

示例15: JavascriptManager

        /// <summary>This creates the table Paginator Control for the Grid</summary>
        public static IHtmlString JavascriptManager(this HtmlHelper helper, string WebConfigEntryName)
        {
            string javascriptSuffix = String.Empty;
            if (ConfigurationManager.AppSettings["ApplicationVersion"] != null)
            {
                javascriptSuffix = "?v=" + ConfigurationManager.AppSettings["ApplicationVersion"].ToString();
            }

            if (String.IsNullOrEmpty(WebConfigEntryName))
                WebConfigEntryName = "MasterPage";
            StringBuilder stringBuilder = new StringBuilder();
            var javascriptString = ConfigurationManager.AppSettings[WebConfigEntryName].ToString().ToLower().Replace("[staticfileurl]", ConfigurationManager.AppSettings["StaticFileURL"].ToString()).Replace("[applicationurl]", ConfigurationManager.AppSettings["ApplicationURL"].ToString());

            var files = javascriptString.Split(',');
            foreach (var file in files)
            {
                if (file.Contains(".css"))
                {
                    stringBuilder.Append("<link href='" + file + javascriptSuffix + "' rel='stylesheet' type='text/css' />");
                }
                if (file.Contains(".js"))
                {
                    stringBuilder.Append("<script src='" + file + javascriptSuffix + "' type='text/javascript'></script>");
                }
            }

            var controlOutput = new System.Web.HtmlString(stringBuilder.ToString());
            return controlOutput;
        }
开发者ID:akatawazi,项目名称:WikiZart,代码行数:30,代码来源:JavascriptManager.cs


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