當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。