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


C# MvcHtmlString.ToString方法代码示例

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


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

示例1: Add

        public Line Add(MvcHtmlString label, MvcHtmlString input, bool show = true)
        {
            string html = "{0}<div class='controls controls-row'>{1}</div>";
            string lbl;
            if (show)
            {
                if (MvcHtmlString.IsNullOrEmpty(label))
                {
                    lbl = "<label class='control-label'>&nbsp;</label>";
                }
                else
                {
                    lbl = label.ToString().Replace("<label ", "<label class='control-label' ");
                }
                html = string.Format(html, lbl, input.ToString());

                //TagBuilder l = new TagBuilder("div");
                //l.AddCssClass("control-group");

                //l.InnerHtml += MvcHtmlString.IsNullOrEmpty(label) ? "<label>&nbsp;</label>" : label.ToString();
                //l.InnerHtml += input.ToString();

                p.InnerHtml += html;
            }

            return this;
        }
开发者ID:odairkreuzberg,项目名称:simetrica,代码行数:27,代码来源:FormHelper.cs

示例2: AppendMvcHtmlString

 protected void AppendMvcHtmlString(MvcHtmlString htmlString)
 {
     if (htmlString != null)
     {
         this.htmlTextWriter.Write(htmlString.ToString());
     }
 }
开发者ID:dwdkls,项目名称:pizzamvc,代码行数:7,代码来源:ModelRendererBase.cs

示例3: AddToRight

        public FormRow AddToRight(MvcHtmlString markup)
        {
            if (markup != null)
            {
                return AddToRight(markup.ToString());
            }

            return this;
        }
开发者ID:justin-arvay,项目名称:Trakker,代码行数:9,代码来源:FormRow.cs

示例4: HighlightPattern_Test

 public void HighlightPattern_Test()
 {
     HtmlHelper helper = null;
     string target = "Spam string spam with spAm pattern sPAm";
     string pattern = "spam";
     string highlightTag = "i";
     MvcHtmlString expected = new MvcHtmlString("<i>Spam</i> string <i>spam</i> with <i>spAm</i> pattern <i>sPAm</i>");
     MvcHtmlString actual;
     actual = HighlightPatternExtension.HighlightPattern(helper, target, pattern, highlightTag);
     Assert.AreEqual(expected.ToString(), actual.ToString());
 }
开发者ID:pengwin,项目名称:SampleProject,代码行数:11,代码来源:HighlightPatternExtensionTest.cs

示例5: CustomTruncate

 public static MvcHtmlString CustomTruncate(this HtmlHelper x, MvcHtmlString s, int nbr)
 {
     var chaine = WebUtility.HtmlDecode(s.ToString());
     if (chaine.Length > nbr)
     {
         return MvcHtmlString.Create(  String.Format("{0}...", chaine.Substring(0,nbr)));
     }
     else
     {
         return s;
     }
 }
开发者ID:pmiossec,项目名称:Delightful,代码行数:12,代码来源:MyHelpers.cs

示例6: Test

        public void Test(string currentDomain, string expectedToken)
        {
            var logger = new FakeLogger();
            var serializer = new FakeDomainSerializer();
            var check = new StaticDomainCheck(logger, serializer);
            var tokenizer = new FakeTokenizer();

            var generator = new AntiforgeryTokenGenerator(check, tokenizer, currentDomain);
            var result = generator.GetAntiForgeryToken();
            var expected = new MvcHtmlString(expectedToken);

            Assert.Equal(expected.ToString(), result.ToString());
        }
开发者ID:frapid,项目名称:frapid,代码行数:13,代码来源:AntiforgeryTokenGeneratorTests.cs

示例7: NavigationItem

		private static MvcHtmlString NavigationItem(this HtmlHelper htmlHelper,
			string controllerName,
			MvcHtmlString innerHtml)
		{
			var tag = new TagBuilder("li");

			var isCurrent = htmlHelper.IsCurrentController(controllerName);
			if (isCurrent)
			{
				tag.AddCssClass("active");
			}

			tag.InnerHtml = innerHtml.ToString();

			return MvcHtmlString.Create(tag.ToString());
		}
开发者ID:dddeeennn,项目名称:esystem,代码行数:16,代码来源:HtmlNavigationExtensions.cs

示例8: CalculateTimeToRead

		public static TimeToRead CalculateTimeToRead(MvcHtmlString body)
		{
			if (body == null)
				return TimeToRead.Empty;

			var bodyAsString = body.ToString();
			var parts = bodyAsString.Split(' ');

			var wordCount = parts.Length;
			var rate = wordCount / 200.0;
			var minutes = (int)rate;
			var seconds = (rate - minutes) * 0.6;
			var minutesAndSeconds = minutes + seconds;
			var timeToReadInMinutes = (int)Math.Ceiling(minutesAndSeconds);

			return new TimeToRead
			{
				TimeToReadInMinutes = timeToReadInMinutes,
				WordCount = wordCount
			};
		}
开发者ID:ayende,项目名称:RaccoonBlog,代码行数:21,代码来源:PostHelper.cs

示例9: Breadcrumbs

 /// <summary>
 /// 
 /// </summary>
 /// <param name="iconClass"></param>
 /// <param name="isFixed"></param>
 /// <param name="items"></param>
 /// <returns></returns>
 public MvcHtmlString Breadcrumbs(string iconClass, List<Nav> items, bool isFixed = false, MvcHtmlString append = null)
 {
     if (items == null || items.Count == 0) throw new ArgumentException("data 参数不能为空!");
     var html = new StringBuilder();
     html.AppendFormat("<div class=\"breadcrumbs{0}\" id=\"breadcrumbs\">", isFixed ? " breadcrumbs-fixed" : string.Empty);
     html.Append("<script>try { ace.settings.check('breadcrumbs', 'fixed') } catch (e) { }</script>");
     html.Append("<ul class=\"breadcrumb\">");
     var flag = 0;
     var icon = string.Format("<i class=\"ace-icon fa {0}\"></i>", iconClass);
     foreach (var item in items)
     {
         if (flag == items.Count - 1)
             html.AppendFormat("<li class=\"active\"> {0} {1}</li>", flag == 0 ? icon : string.Empty, item.Text);
         else
             html.AppendFormat("<li>{0}<a href = \"{1}\" > {2} </a></li>", flag == 0 ? icon : string.Empty, item.Url, item.Text);
         flag++;
     }
     html.Append("</ul>");
     if (append != null) html.Append(append.ToString());
     html.Append("</div>");
     return MvcHtmlString.Create(html.ToString());
 }
开发者ID:liujunhua,项目名称:Smart,代码行数:29,代码来源:AceHtmlHelper.cs

示例10: BootstrapControlGroup

        public static MvcHtmlString BootstrapControlGroup(this HtmlHelper htmlHelper, MvcHtmlString htmlLabel, MvcHtmlString htmlEditor, MvcHtmlString htmlValidator, MvcHtmlString htmlHelpText)
        {
            TagBuilder builder = new TagBuilder("div");
            builder.AddCssClass("control-group");
            builder.InnerHtml += htmlLabel;

            TagBuilder div = new TagBuilder("div");
            div.AddCssClass("controls");
            div.InnerHtml += htmlEditor;

            div.InnerHtml += htmlValidator;
            
            if (htmlHelpText != null && !string.IsNullOrEmpty(htmlHelpText.ToString()))
            {
                TagBuilder p = new TagBuilder("p");
                p.AddCssClass("help-block");
                p.InnerHtml += htmlHelpText;
                div.InnerHtml += p;
            }

            builder.InnerHtml += div;

            return MvcHtmlString.Create(builder.ToString());
        }
开发者ID:jgennari,项目名称:Mvc.Bootstrap,代码行数:24,代码来源:Fields.cs

示例11: PageLinkAssert

 private void PageLinkAssert(MvcHtmlString htmlString)
 {
     Assert.AreEqual(htmlString.ToString(), @"<a href=""Page1"">1</a>"
        + @"<a class=""selected"" href=""Page2"">2</a>"
        + @"<a href=""Page3"">3</a>");
 }
开发者ID:QuetzalCoatlus,项目名称:SportsStore,代码行数:6,代码来源:PageLinkTest.cs

示例12: AddToLeft

 public FormRow AddToLeft(MvcHtmlString markup)
 {
     return AddToLeft(markup.ToString());
 }
开发者ID:justin-arvay,项目名称:Trakker,代码行数:4,代码来源:FormRow.cs

示例13: ReplaceGuidWithRealText

 private static MvcHtmlString ReplaceGuidWithRealText(string linkText, MvcHtmlString linkString)
 {
     return new MvcHtmlString(linkString.ToString().Replace(guid, linkText));
 }
开发者ID:JWroe,项目名称:HelperLibrary,代码行数:4,代码来源:HtmlExtensions.cs

示例14: OperateGuanJianZiHuiFu

        public ActionResult OperateGuanJianZiHuiFu(FormCollection fc, GuanJianZiHuiFuContract pc, string id, string url)
        {
            #region 绑定关键字回复内容所属的关键字
            List<GuanJianZiHuiFuTypeContract> list = new List<GuanJianZiHuiFuTypeContract>();
            //获取所有的关键字类型
            List<GuanJianZiHuiFuType> dsGJZType = hfs.GetAllGJZType();

            foreach (var item in dsGJZType)
            {
                GuanJianZiHuiFuTypeContract emp = new GuanJianZiHuiFuTypeContract();
                emp.trueId = Convert.ToInt32(item.trueId);
                emp.name = item.name;
                list.Add(emp);
            }

            ViewData["gjz"] = new SelectList(list, "trueId", "name");
            #endregion

            #region 绑定企业
            List<employeeInfo> listEmp = null;
            if ((Session["user"] as UsersContract).RoleID == 1)
            {
                #region 系统管理员 获取所有企业信息
                listEmp = gs.GetAllEmp();
                #endregion
            }
            else
            {
                #region 获取自己的关键字
                listEmp = gs.GetAllEmp((Session["user"] as UsersContract).EId);
                #endregion
            }
            //获取所有的企业

            ViewData["emp"] = new SelectList(listEmp, "Eid", "wxName");
            #endregion

            var countent = new MvcHtmlString(pc.content);
            pc.content = countent.ToString();

            //图文图片
            string img = fc["willUploadImg"];

            //判断要添加的关键字是否已经存在
            //if (hfs.IsExists(pc.content, pc.gjzId.ToString(), id))
            //{
            //    //执行失败信息
            //    ViewData["msg"] = "要添加的回复内容已经存在,请先确认!";
            //    //失败视图
            //    return View("Error");
            //}
            //else
            //{
            pc.time = DateTime.Now.ToString();
            pc.img = img;
            switch (ModelState.IsValid)
            {
                case true:

                    //如果要修改的编号为null,则为添加回复信息操作
                    if (id != null && id == "0")
                    {
                        if (hfs.AddGuanJianZiHuiFu(pc) > 0)
                        {
                            //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                            ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiHuiFuMain");

                            //执行成功信息
                            ViewData["msg"] = "添加回复内容成功!";
                            //成功视图
                            return View("Success");
                        }
                        else
                        {
                            //执行成功信息
                            ViewData["msg"] = "添加回复内容失败!";
                            return View("Error");
                        }
                    }
                    else
                    {
                        pc.gjzId = int.Parse(fc["gjzId"]);
                        if (hfs.UpdateGuanJianZiHuiFu(pc) > 0)
                        {
                            //执行成功信息
                            ViewData["msg"] = "修改回复内容成功!";
                            //成功后要跳转的路径(如果无须跳转,直接留在当前页面,不写即可)
                            ViewData["url"] = new UrlHelper(Request.RequestContext).Action("GuanJianZiHuiFuMain");
                            //成功视图
                            return View("Success");
                        }
                        else
                        {
                            ViewData["msg"] = "修改关回复内容失败!";
                            return View("Error");
                        }
                    }
                default:
                    ViewBag.pTitle = "添加回复内容信息";
                    return View(new GuanJianZiHuiFuContract());
//.........这里部分代码省略.........
开发者ID:refinedKing,项目名称:WeiXin--Vs2010-,代码行数:101,代码来源:WeiXinController.cs

示例15: ToSslLink

 /// <summary>
 /// Looks for Html links in the passed string and turns each relative or absolute url into a fully-qualified url path using the Https protocol.
 /// </summary>
 /// <param name="text">The url to make fully-qualified. Ex: <a href="Home/About">Blah</a></param>
 /// <returns>The absolute url plus server, & port using the Https protocol. Ex: <a href="https://localhost:1234/Home/About">Blah</a></returns>
 public virtual MvcHtmlString ToSslLink(MvcHtmlString text)
 {
     // TODO: This won't work with .NET 4
     if (!UseSsl()) return text;
     return MvcHtmlString.Create(ToFullyQualifiedLink(text.ToString()).Replace("http:", "https:"));
 }
开发者ID:sthapa123,项目名称:sutekishop,代码行数:11,代码来源:UrlExtensionsHelper.cs


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