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;
 }
		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/>"));
		}
示例#3
0
 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);
 }
示例#4
0
        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;
        }
        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());
        }
        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;
        }
示例#7
0
    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();
    }
示例#8
0
        public virtual void Render(string controllerName = "", string actionName = "")
        {
            if (this.viewEnabled)
            {
                if (controllerName.Length == 0)
                {
                    controllerName = this.request.Params["controller"].ToString();
                }
                if (actionName.Length == 0)
                {
                    actionName = this.request.Params["action"].ToString();
                }
                // complete paths
                string controllerPath = controllerName.Replace('_', '/').Replace(@"\\", "/");
                string viewScriptPath = String.Join("/", new string[] {
                    controllerPath, actionName
                });
                // render content string
                string actionResult = this.view.RenderScript(viewScriptPath);
                // create parent layout view, set up and render to outputResult

                View layout = Activator.CreateInstance(
                    MvcCore.Application.GetInstance().GetViewClass(),
                    new object[] { this }
                    ) as View;
                layout.SetUp(this.view);
                layout["Content"] = new System.Web.HtmlString(actionResult);
                string outputResult = layout.RenderLayoutAndContent(this.layout, actionResult);
                layout    = null;
                this.view = null;
                // send response and exit
                this.HtmlResponse(outputResult);
                this.DisableView();                 // disable to not render it again
            }
        }
示例#9
0
 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;
 }
 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);
 }
 /*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;
 }
 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;
 }
示例#13
0
 public FormGroup(HtmlString input, HtmlString label, FormGroupType type, bool fieldIsValid = true)
 {
     _input = input;
     _label = label;
     _type = type;
     _fieldIsValid = fieldIsValid;
 }
示例#14
0
        /// <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;
        }
示例#15
0
 public ActionResult agregarHistoria(int id)
 {
     var Jugadora = db.jugadora.FirstOrDefault(e => e.idJugadora.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Jugadora.historia));
     Jugadora.historia = h.ToString();
     return View(Jugadora);
 }
示例#16
0
 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);
 }
示例#17
0
        /// <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;
        }
示例#18
0
 public ActionResult agregarHistoria(int id)
 {
     var Equipo = db.equipo.FirstOrDefault(e => e.idEquipo.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Equipo.historia));
     Equipo.historia = h.ToString();
     return View(Equipo);
 }
 public ActionResult AreaOverview()
 {
     var page = db.GetPage("Area Overview");
     IHtmlString str = new HtmlString(page.HtmlPageContent);
     ViewBag.HtmlPageDisplay = str;
     return View();
 }
        public bool Init(int CurrentNodeId, string PropertyData, out object instance)
        {
			//we're going to send the string through the macro parser and create the output string.
			if (UmbracoContext.Current != null)
			{
				var sb = new StringBuilder();
				var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
				MacroTagParser.ParseMacros(
					PropertyData,
					//callback for when text block is found
					textBlock => sb.Append(textBlock),
					//callback for when macro syntax is found
					(macroAlias, macroAttributes) => sb.Append(umbracoHelper.RenderMacro(
						macroAlias,
						//needs to be explicitly casted to Dictionary<string, object>
						macroAttributes.ConvertTo(x => (string)x, x => (object)x)).ToString()));
				instance = new HtmlString(sb.ToString());
			}			
			else
			{
				//we have no umbraco context, so best we can do is convert to html string
				instance = new HtmlString(PropertyData);
			}			
            return true;
        }
示例#21
0
 public ActionResult agregarImagenPrincipal(int id)
 {
     var Noticia = db.noticia.FirstOrDefault(e => e.idNoticia.Equals(id));
     var h = new HtmlString(HttpUtility.HtmlDecode(Noticia.contenido));
     Noticia.imagenPrincipal = h.ToString();
     return View(Noticia);
 }
示例#22
0
 public ActionResult Index()
 {
     GameOfLifeHelpers.InitializeGame();
     GameOfLifeHelpers.AddGlider(GameOfLifeHelpers.arrOne, 10, 10);
     GameOfLifeHelpers.DrawStartIteration();
     HtmlString table = new HtmlString(GameOfLifeHelpers.table.ToString());
     return View(table);
 }
示例#23
0
 public static HtmlString Script(this HtmlHelper helper, string fileName)
 {
     if (!fileName.EndsWith(".js"))
         fileName += ".js";
     var jsPath = new HtmlString(string.Format("<script src='{0}/{1}/{2}' ></script>\n",
         pubDir, scriptDir, helper.AttributeEncode(fileName)));
     return jsPath;
 }
示例#24
0
        public ActionResult Index(WebPageView webPageView)
        {
            var Web = new WebPageView();
            Web = webPageView;

            var html = new HtmlString(Web.Url);
            return View("Detail", Web);
        }
 internal void ExecuteInternal() {
     // See comments in GetSafeExecuteStartPageThunk().
     _safeExecuteStartPageThunk(() => {
         Output = new StringWriter(CultureInfo.InvariantCulture);
         Execute();
         Markup = new HtmlString(Output.ToString());
     });
 }
示例#26
0
 public static HtmlString CSS(this HtmlHelper helper, string fileName, string media)
 {
     if (!fileName.EndsWith(".css"))
         fileName += ".css";
     var jsPath = new HtmlString(string.Format("<link rel='stylesheet' type='text/css' href='{0}/{1}/{2}'  media='" + media + "'/>\n",
         pubDir, cssDir, helper.AttributeEncode(fileName)));
     return jsPath;
 }
示例#27
0
 public HtmlListModel()
 {
     Elements = new List<HtmlString>(3);
     HtmlString hs1 = new HtmlString("<div>Testiranje bbbb.</div>");
     Elements.Add(hs1);
     Elements.Add(hs1);
     Elements.Add(hs1);
 }
        public ActionResult ExtrasDetail1()
        {
            var page = db.GetPage("Extras Link 1");
            var reviews = db.GetPage("Reviews");
            IHtmlString str = new HtmlString(page.HtmlPageContent + reviews.HtmlPageContent);
            ViewBag.HtmlPageDisplay = str;

            return View();
        }
        public void ToHtmlTag_GivenImageTag_ShouldReturnImageHtmlSelfEnclose()
        {
            var tagBuilder = new TagBuilder("img");
            var htmlString = new HtmlString(tagBuilder.ToString());

            var htmlTag = HtmlTagExtensions.ToHtmlTag(htmlString);

            Check.That(htmlTag.ToHtmlString()).IsEqualTo("<img />");
        }
示例#30
0
        public void Initialize(Sitecore.Mvc.Presentation.Rendering rendering)
        {
            Rendering = rendering;
            Item = rendering.Item;
            PageItem = PageContext.Current.Item;

            Make = new HtmlString(FieldRenderer.Render(Item, "Make"));
            Model = new HtmlString(FieldRenderer.Render(Item, "Model"));
        }
示例#31
-1
        public SessionViewModel(Item item)
        {
            Subject = item.GetString(new ID(Constants.Fields.Session.Subject));
            Description = item.GetString(new ID(Constants.Fields.Session.Description));
            Text = new HtmlString(item.GetString(new ID(Constants.Fields.Session.Text)));

        }