public static string GenerateMenuHorizontalHtml(this IEnumerable <Menu> enumerable) { var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.Write("jQuery(function () {" + "jQuery('#example').superfish({});" + "$(\"ul.sf-menu li\").addClass(\"ui-state-default\");" + "$(\"ul.sf-menu li\").hover(function () { $(this).addClass('ui-state-hover'); }," + "function () { $(this).removeClass('ui-state-hover'); });});"); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Style, "direction:" + Resources.Design.Direction + ";"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "sf-menu"); writer.AddAttribute(HtmlTextWriterAttribute.Style, "float: " + Resources.Design.Align + ";"); writer.AddAttribute(HtmlTextWriterAttribute.Id, "example"); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in enumerable) { if (string.IsNullOrEmpty(menu.Text)) { continue; } var link = !menu.Link.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Link : menu.Link; writer.AddAttribute(HtmlTextWriterAttribute.Class, "current"); writer.AddAttribute(HtmlTextWriterAttribute.Style, "float: " + Resources.Design.Align + ";"); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, link); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(" " + menu.Text); writer.RenderEndTag(); if (menu.Children.Count > 0) { GenerateChildMenuHorizontal(ref writer, menu); } writer.RenderEndTag(); } writer.RenderEndTag(); writer.RenderEndTag(); return(stringWriter.ToString()); }
public void WriteTo(Html32TextWriter writer, List <string> classNames, ICssClassMapper classMapper) { foreach (char c in GetPrecedingPattern()) { writer.Write(c); } string[] spanClassNames; RegexParser.WriteSpanned(_name, writer, classNames, classMapper.TryGetNameClassNames(out spanClassNames) ? spanClassNames : null); foreach (char c in GetFollowingPattern()) { writer.Write(c); } }
/// <summary> /// Writes the navigation bar to the given <see cref="Html32TextWriter"/>. /// </summary> /// <param name='htw'> /// The <see cref="Html32TextWriter"/> to write the content to. /// </param> /// <param name='webpage'> /// The webpage that is currently displayed. This is needed to denote the current page. /// </param> private void WriteMasthead(Html32TextWriter htw, IWebPage webpage) { INavbar navbar = this.device.Navigationbar; htw.AddAttribute(HtmlTextWriterAttribute.Class, "navbar navbar-default navbar-fixed-top"); htw.AddAttribute("role", "navigation"); htw.RenderBeginTag(HtmlTextWriterTag.Div); { htw.AddAttribute(HtmlTextWriterAttribute.Class, "container-fluid"); htw.RenderBeginTag(HtmlTextWriterTag.Div); { htw.AddAttribute(HtmlTextWriterAttribute.Class, "navbar-header"); htw.RenderBeginTag(HtmlTextWriterTag.Div); { htw.AddAttribute(HtmlTextWriterAttribute.Class, "navbar-brand"); htw.AddAttribute(HtmlTextWriterAttribute.Href, "#"); htw.RenderBeginTag(HtmlTextWriterTag.A); { htw.Write(navbar.Name); } htw.RenderEndTag(); } htw.RenderEndTag(); htw.AddAttribute(HtmlTextWriterAttribute.Class, "navbar-collapse collapse"); htw.RenderBeginTag(HtmlTextWriterTag.Div); { htw.AddAttribute(HtmlTextWriterAttribute.Class, "nav navbar-nav"); htw.RenderBeginTag(HtmlTextWriterTag.Ul); { foreach (IWebPage wp in navbar.Pages) { if (wp == webpage) { htw.AddAttribute(HtmlTextWriterAttribute.Class, "active"); } htw.RenderBeginTag(HtmlTextWriterTag.Li); htw.AddAttribute(HtmlTextWriterAttribute.Href, wp.Href); htw.RenderBeginTag(HtmlTextWriterTag.A); htw.Write(wp.Name); htw.RenderEndTag(); htw.RenderEndTag(); } } htw.RenderEndTag(); } htw.RenderEndTag(); } htw.RenderEndTag(); } htw.RenderEndTag(); }
private static void GenerateChildMenuHorizontal(ref Html32TextWriter writer, Menu getmenu) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "sf-menu childUl"); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in getmenu.Children) { if (string.IsNullOrEmpty(menu.Text)) { continue; } var link = !menu.Link.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Link : menu.Link; writer.AddAttribute(HtmlTextWriterAttribute.Class, "current sc"); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, link); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.Write(" " + menu.Text); writer.RenderEndTag(); if (menu.Children.Count > 0) { GenerateChildMenuHorizontal(ref writer, menu); } writer.RenderEndTag(); } writer.RenderEndTag(); }
public static string GenerateMenuHorizontalVertical(this IEnumerable <Menu> enumerable) { var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.AddAttribute(HtmlTextWriterAttribute.Class, "row"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-12"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "widget"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "cssmenu"); writer.RenderBeginTag(HtmlTextWriterTag.Div); var count = 1; int modelcount = enumerable.Count(); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in enumerable) { if (string.IsNullOrEmpty(menu.Text)) { continue; } var link = !menu.Link.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Link : menu.Link; if (menu.Children.Count > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "active has-sub"); } else if (count == modelcount) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "last"); } writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, link); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(menu.Text); writer.RenderEndTag(); writer.RenderEndTag(); if (menu.Children.Count > 0) { GenerateChildMenuVertical(ref writer, menu); } writer.RenderEndTag(); count++; } writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); return(stringWriter.ToString()); }
public static void LanguageDropDownList(this HtmlHelper helper, string onchangefunction = null, string Id = "LanguageId", IEnumerable <Language> customeList = null) { var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Class.ToString(), "table-row-cap"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Class.ToString(), "item"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); html32TextWriter.Write(Resources.Common.Language); html32TextWriter.RenderEndTag(); html32TextWriter.RenderEndTag(); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Class.ToString(), "table-row-item"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Class.ToString(), "item"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); GenerateDrp(html32TextWriter, SessionParameters.Culture, onchangefunction, Id, customeList); html32TextWriter.RenderEndTag(); html32TextWriter.RenderEndTag(); var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
private static void GenerateDrp(Html32TextWriter html32TextWriter, string selectedlang, string onchangefunction = null, string Id = "LanguageId", IEnumerable <Language> customeList = null) { var listlang = customeList ?? CommonComponent.Instance.LanguageFacade.GetValidList().ToList(); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), Id); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), Id); if (!string.IsNullOrEmpty(onchangefunction)) { html32TextWriter.AddAttribute("onchange", onchangefunction); } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Style.ToString(), "width:80px;height:25px;vertical-align: top;margin-left: 10px;"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Select.ToString()); foreach (var language in listlang) { if (language.Id == selectedlang) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Selected.ToString(), "selected"); } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), language.Id); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Option.ToString()); html32TextWriter.Write(language.DisplayName); html32TextWriter.RenderEndTag(); } html32TextWriter.RenderEndTag(); }
/// <summary> /// Render an items tree for specified list /// </summary> /// <param name="list">The content list object</param> /// <param name="current">The content data item object.</param> /// <param name="htmlAttributes">The html attributes object.</param> /// <returns></returns> public static HelperResult Tree(ContentListDecorator list, ContentDataItemDecorator current = null, object htmlAttributes = null) { return(new HelperResult((w) => { using (var writer = new Html32TextWriter(w)) { writer.WriteBeginTag("ul"); writer.WriteAttribute("data-role", "tree"); if (htmlAttributes != null) { var dict = htmlAttributes.ToDictionary(); foreach (var key in dict.Keys) { if (key.StartsWith("data_")) { writer.WriteAttribute(key.Replace("_", "-"), (string)dict[key]); } else { writer.WriteAttribute(key, (string)dict[key]); } } } writer.Write(Html32TextWriter.TagRightChar); var items = list.GetItems(i => i.ParentItemID == Guid.Empty && i.IsPublished && i.IsCurrentVersion).OrderBy(i => i.Pos); RenderChildren(writer, list, items, current); writer.WriteEndTag("ul"); } })); }
public void RenderCommissionCheckAmountInEnglish(decimal amount) { NumberToEnglish converter = new NumberToEnglish(); string amountString = converter.ChangeCurrencyToWords(Convert.ToDouble(amount)); Html32TextWriter writer = new Html32TextWriter(Response.Output); writer.Write(amountString); }
public override void WriteTo(Html32TextWriter writer, List <string> classNames, ICssClassMapper classMapper) { switch (Type) { case QuantifierType.Optional: writer.Write(IsLazy ? "??" : "?"); break; case QuantifierType.OptionalRepeat: writer.Write(IsLazy ? "*?" : "*"); break; default: writer.Write(IsLazy ? "+?" : "+"); break; } }
public static void WriteValue(this Html32TextWriter w, int value) { w.WriteFullBeginTag("td"); if (value != 0) { w.Write(value); } w.WriteEndTag("td"); }
/// <summary> /// Writes a footer of every webpage to the given <see cref="Html32TextWriter"/> instance. /// </summary> /// <param name='htw'> /// The <see cref="Html32TextWriter"/> to write the webpage to. /// </param> private void WriteFooter(Html32TextWriter htw) { htw.RenderBeginTag(HtmlTextWriterTag.Hr); htw.RenderEndTag(); htw.AddAttribute(HtmlTextWriterAttribute.Class, "footer"); htw.RenderBeginTag(HtmlTextWriterTag.Div); htw.RenderBeginTag(HtmlTextWriterTag.P); htw.Write("This page is created with {0}", ProgramManager.ProgramNameVersion); htw.RenderEndTag(); htw.RenderEndTag(); }
public static void WriteValue(this Html32TextWriter w, string value, string classname) { w.WriteBeginTag("td"); w.WriteAttribute("class", classname); w.Write(">"); if (!string.IsNullOrEmpty(value)) { w.WriteEncodedText(value); } w.WriteEndTag("td"); }
public static void GenerateMenuHorizontalVertical(this HtmlHelper helper, IEnumerable <Menu> enumerable, string Id) { var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Class, "list-nav nav-panel menu-item"); writer.AddAttribute(HtmlTextWriterAttribute.Id, Id); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in enumerable) { var value = !menu.Url.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Url : menu.Url; writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, value); if (menu.Children.Count > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown-btn"); } writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Class, "img-nav"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Src, "/RadynFileHandler/" + menu.ImageId); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); //img writer.RenderEndTag(); //div.img-nav writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(menu.Title); writer.RenderEndTag(); //span writer.RenderEndTag(); //a.dropdown-btn if (menu.Children.Count > 0) { GenerateChildMenuVertical(ref writer, menu); } writer.RenderEndTag();//li } writer.RenderEndTag(); //ul.list-nav writer.RenderEndTag(); //li helper.ViewContext.Writer.Write(stringWriter.ToString()); }
public override void WriteTo(Html32TextWriter writer, List <string> classNames, ICssClassMapper classMapper) { writer.Write('{'); string[] spanClassNames; if (!classMapper.TryGetNameClassNames(out spanClassNames)) { spanClassNames = null; } RegexParser.WriteSpanned(MinValue, writer, classNames, spanClassNames); switch (Type) { case QuantifierType.Limited: writer.Write(","); RegexParser.WriteSpanned(MaxValue, writer, classNames, spanClassNames); break; case QuantifierType.MinRepeat: writer.Write(","); break; } writer.Write(IsLazy ? "}?" : "}"); }
private static void GenerateChildMenuVertical(ref Html32TextWriter writer, Menu getmenu) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown-container"); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in getmenu.Children) { var value = !menu.Url.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Url : menu.Url; writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, value); if (menu.Children.Count > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "dropdown-btn"); } writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Class, "img-nav"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Src, "/RadynFileHandler/" + menu.ImageId); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); //img.icon-upper writer.RenderEndTag(); //div.img-nav writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(menu.Title); writer.RenderEndTag();//span //writer.AddAttribute(HtmlTextWriterAttribute.Src, String.Format("/Scripts/Radyn/RadynMenu/imgaes/keyboard_arrow_{0}.png", Resources.Design.Direction)); //writer.AddAttribute(HtmlTextWriterAttribute.Class, "icon-upper"); //writer.RenderBeginTag(HtmlTextWriterTag.Img); //writer.RenderEndTag();//img.icon-upper writer.RenderEndTag();//a.dropdown-btn if (menu.Children.Count > 0) { GenerateChildMenuVertical(ref writer, menu); } writer.RenderEndTag();//li } writer.RenderEndTag(); }
private static void GenerateChildMenuVertical(ref Html32TextWriter writer, Menu getmenu) { var count = 1; var childcount = getmenu.Children.Count; writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var menu in getmenu.Children) { if (string.IsNullOrEmpty(menu.Text)) { continue; } var link = !menu.Link.StartsWith("http://") ? Radyn.Web.Mvc.UI.Application.CurrentApplicationPath + menu.Link : menu.Link; if (menu.Children.Count > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "has-sub"); } else if (count == childcount) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "last"); } writer.RenderBeginTag(HtmlTextWriterTag.Li); writer.AddAttribute(HtmlTextWriterAttribute.Href, link); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(menu.Text); writer.RenderEndTag(); writer.RenderEndTag(); if (menu.Children.Count > 0) { GenerateChildMenuVertical(ref writer, menu); } writer.RenderEndTag(); count++; } writer.RenderEndTag(); }
public void writeABCInfo() { //_doc.Write("<p>Submitting photos to AZFO does not constitute reporting a rare bird for consideration as an official record. To ensure that a record becomes official, details or photos of Sketch Details Species should be sent to the editors of North American Birds here and a full report of Review Species should be submitted to the Arizona Bird Committee here. Most rare birds are under _documented and subsequent observers of a rarity are always encouraged to submit reports and additional photos, especially for birds that are challenging to identify.</p>"); _doc.Write(@"<p> Submitting photos to AZFO does not constitute reporting a rare bird for consideration as an official record. To ensure that a record becomes official, details or photos of Sketch Details Species should be sent to the <a href='http://www.azfo.org/gallery/NABEditors.html'>Editors of North American Birds</a> and a full report of Review Species should be submitted to the <a href='http://www.azfo.org/gallery/whatIsABC.html'>Arizona Bird Committee</a>. Most rare birds are under _documented and subsequent observers of a rarity are always encouraged to submit reports and additional photos, especially for birds that are challenging to identify.</P>" ); }
private static void WriteControl <TModel>(HtmlHelper helper, TModel obj, ComponentMode componentMode, int width, int height, bool showDrp, string name, string DrpName = "LanguageId", bool showemptyvalue = false) where TModel : class { var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); LanguageContent content = null; content = LanguageContent(obj, name, showemptyvalue); if (!showDrp) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), DrpName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), DrpName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), SessionParameters.Culture); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } else { var culture = content != null ? content.LanguageId : SessionParameters.Culture; GenerateDrp(html32TextWriter, culture, "$.get('/Common/LanguageContent/ChangeCulture',{key:document.getElementById('LHK-" + name + "').value,langid:document.getElementById('LanguageId').value,date: new Date().getTime()},function(data){if(data!=null){document.getElementById('" + name + "').value=data;}});", DrpName); } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "LHK-" + name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "LHK-" + name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); var str = ""; if (content != null) { str = content.Value; html32TextWriter.Write("<script>document.getElementById('LHK-" + name + "').value='" + content.Key + "'</script>"); } else { var val = obj.GetType().GetProperty(name).GetValue(obj, null); if (val != null) { str = val.ToString(); } } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), str); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), name); switch (componentMode) { case ComponentMode.TextBox: html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Style.ToString(), "width:" + width + "px;"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "text"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); break; case ComponentMode.TextArea: var style = ""; if (width > 0) { style += "width:" + width + "px;"; } if (height > 0 && componentMode != ComponentMode.TextBox) { style += "height:" + height + "px;"; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Style.ToString(), style); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Textarea.ToString()); html32TextWriter.Write(str); html32TextWriter.RenderEndTag(); break; } var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
public string GetCongressResourceHtml(IConnectionHandler connectionHandler, Guid congressId, string culture, Enums.UseLayout layout) { try { var str = new StringWriter(); var html32TextWriter = new Html32TextWriter(str); var byFilter = new ResourceBO().OrderBy(connectionHandler, x => x.Order, x => x.CongressId == congressId && x.Enabled); if (!string.IsNullOrEmpty(culture)) { new ResourceBO().GetLanuageContent(connectionHandler, culture, byFilter); } foreach (var resource in byFilter) { if (layout != Enums.UseLayout.None && (string.IsNullOrEmpty(resource.UseLayoutId) || (!resource.UseLayoutId.Split(',').Contains(((byte)layout).ToString())))) { continue; } switch ((Enums.ResourceType)resource.Type) { case Enums.ResourceType.JSFile: if (resource.FileId == null) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Src, FileManagerContants.FileHandlerRoot + resource.FileId); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Script); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.CssFile: if (resource.FileId == null) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Href, FileManagerContants.FileHandlerRoot + resource.FileId); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Link); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.JSFunction: if (string.IsNullOrEmpty(resource.Text)) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style); html32TextWriter.Write(resource.Text); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.Style: if (string.IsNullOrEmpty(resource.Text)) { continue; } html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style); html32TextWriter.Write(resource.Text); html32TextWriter.RenderEndTag(); break; } } return(str.ToString()); } catch (KnownException knownException) { throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { throw new KnownException(ex.Message, ex); } }
public static void ImgeControlWithCulture <TModel>(this HtmlHelper helper, TModel obj, Expression <Func <TModel, string> > value, bool download = false, int width = 100, int height = 100) where TModel : class { var s = value.Body.ToString(); var lastIndexOf = s.LastIndexOf("."); var name = s.Substring(lastIndexOf + 1, s.Length - lastIndexOf - 1); var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "LHK-" + name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "LHK-" + name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Align.ToString(), "absmiddle"); var style = ""; if (width > 0) { style += "width:" + width + "px;"; } if (height > 0) { style += "height:" + height + "px;"; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Style.ToString(), style); var objectkeyskey = obj.GetCultureKeys(); if (!objectkeyskey.Keys.Contains(name)) { return; } var imagevalue = "/RadynFileHandler/"; var content = LanguageContent(obj, name); if (content != null) { html32TextWriter.Write("<script>document.getElementById('LHK-" + name + "').value='" + content.Key + "'</script>"); imagevalue += content.Value; } else { var val = obj.GetType().GetProperty(name).GetValue(obj, null); if (val != null) { imagevalue += val; } } if (download) { imagevalue += "?dl=true"; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Src.ToString(), imagevalue); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Img.ToString()); html32TextWriter.RenderEndTag(); var culture = content != null?content.LanguageId:SessionParameters.Culture; GenerateDrp(html32TextWriter, culture, "$.get('@ApplicationSettings.MVcDnnPath/Common/LanguageContent/ChangeCulture',{key:document.getElementById('LHK-" + name + "').value,langid:document.getElementById('LanguageId').value,date: new Date().getTime()},function(data){if(data!=null){document.getElementById('" + name + "').src='/RadynFileHandler/'+data" + (download ? "?dl=true" : "") + ";}});"); var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
private static void AddTag(ref TagBuilder sbElements, Controller outcontroller, string htmlTitle, HtmlTagList list, IEnumerable <PartialLoad> partialLoads, string resourceHtml, Guid htmlId, bool desginemode = false) { foreach (HtmlTag htmlTag in list) { var tag = htmlTag.NextTag; if (tag == null) { continue; } if (string.IsNullOrEmpty(tag.Name)) { continue; } var span = new TagBuilder(tag.Name); if (tag.Name == "theme" && !string.IsNullOrEmpty(resourceHtml)) { span.InnerHtml = resourceHtml; } if (tag.Name == "title") { span.SetInnerText(htmlTitle); } if (tag.NextTag != null && tag.NextTag.IsText) { var text = tag.NextTag.Text; if (!string.IsNullOrEmpty(text.Trim()) && text.Trim() != "\r\n") { span.SetInnerText(text); } } foreach (HtmlAttribute attribute in tag.Attributes) { if (attribute.Name == "Radyn.Web.Parser.HtmlAttribute") { continue; } if (span.Attributes.ContainsKey(attribute.Name)) { span.Attributes[attribute.Name] = tag.Attributes.AttributeValue(attribute.Name); } else { span.Attributes.Add(attribute.Name, tag.Attributes.AttributeValue(attribute.Name)); } } string str; span.Attributes.TryGetValue("customid", out str); if (span.Attributes.Count > 0 && !string.IsNullOrEmpty(str)) { var attributeValue = span.Attributes["customid"]; var enumerable = partialLoads.Where(load => load.CustomId == attributeValue).OrderBy(load => load.position); if (enumerable.Any()) { foreach (var partialLoad in enumerable) { if (desginemode) { var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.AddAttribute(HtmlTextWriterAttribute.Class, "row-edit mElement"); writer.AddAttribute("onmouseover", "visible(this);GetDragedItem('" + partialLoad.position + "');"); writer.AddAttribute("onmouseout", "HideMenu(this);"); writer.AddAttribute("id", "row_" + partialLoad.CustomId + "_" + partialLoad.PartialId + "_" + htmlId); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.Write(partialLoad.Html); writer.RenderEndTag(); writer.AddAttribute("id", "Order_" + partialLoad.CustomId + "_" + partialLoad.position); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderEndTag(); var radynRenderActionUrl = outcontroller.RadynRenderActionUrl( "/ContentManager/UIDesginPanel/GetEditNavbar?PartialId=" + partialLoad.PartialId + "&CustomId=" + partialLoad.CustomId + "&htmlId=" + htmlId + "&PartialName=" + (partialLoad.Partials != null ? partialLoad.Partials.Title : (partialLoad.Content != null ? partialLoad.Content.Title : ""))); writer.Write(radynRenderActionUrl); writer.RenderEndTag(); span.InnerHtml += stringWriter.ToString(); } else { span.InnerHtml += partialLoad.Html; } } } else { if (desginemode) { span.Attributes.Add("onmouseover", "GetDragedItem('0');"); span.Attributes.Add("onmouseout", "HideMenu(this);"); var spanAttribute = "row_" + attributeValue + "_" + htmlId; if (!span.Attributes.ContainsKey("id")) { span.Attributes.Add("id", spanAttribute); } else { span.Attributes["id"] = spanAttribute; } span.InnerHtml += String.Format("<div id=\"Order_{0}_0\"></div>", attributeValue); } } } if (tag.Tags.Count > 0) { AddTag(ref span, outcontroller, htmlTitle, tag.Tags, partialLoads, resourceHtml, htmlId, desginemode); } sbElements.InnerHtml += span; } }
public string GetNewAdvertisement(string positionId, string sPkeyword) { try { var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); //دریافت تبلیغ جدید از صف تبلیغات قابل اجرا var sectionPosition = new AdvertisementSectionPositionBO().GetByKeyWord(this.ConnectionHandler, sPkeyword); if (sectionPosition != null) { var advertisement = AdvertisementQueue.POP(sectionPosition); if (advertisement.Timeout >= 0) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.WriteEncodedText(string.Format("SetInterval('{0}',{1},'{2}');", positionId, advertisement.Timeout, sectionPosition.KeyWord)); writer.RenderEndTag(); } writer.AddAttribute("onclick", string.Format("OnAdvClick('{0}');", advertisement.Id)); //تولید قالب تبلیغات بر حسب نوع آن switch (advertisement.AdvertisementType.Type) { case "Text": #region TEXT if (string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.WriteEncodedText(advertisement.Text); } else { writer.AddAttribute("href", advertisement.NavigateUrl); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.WriteEncodedText(Utils.ConvertHtmlToString(advertisement.Text)); writer.RenderEndTag(); } break; #endregion case "Flash": #region FLASH writer.AddAttribute("codeBase", "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7.0.19.0"); writer.AddAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"); writer.AddAttribute("width", advertisement.width.ToString()); writer.AddAttribute("height", advertisement.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Object); writer.AddAttribute("NAME", "Movie"); writer.AddAttribute("VALUE", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.RenderBeginTag(HtmlTextWriterTag.Param); writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.AddAttribute("quality", "high"); writer.AddAttribute("wmode", "opaque"); writer.AddAttribute("pluginspage", "https://www.macromedia.com/go/getflashplayer"); writer.AddAttribute("type", "application/x-shockwave-flash"); writer.AddAttribute("width", advertisement.width.ToString()); writer.AddAttribute("height", advertisement.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Embed); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); break; #endregion case "Html": #region HTML writer.Write(Utils.ConvertHtmlToString(advertisement.Text)); break; #endregion case "Image": #region IMAGE if (!string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.AddAttribute("href", advertisement.NavigateUrl); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); } writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.AddAttribute("border", "0"); writer.AddAttribute("height", advertisement.Height.ToString()); writer.AddAttribute("width", advertisement.width.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); if (!string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.RenderEndTag(); } break; #endregion } //یک واحد به تعداد نمایش تبلیغ اضافه می شود advertisement.VisitCount++; if (!new AdvertisementBO().Update(this.ConnectionHandler, advertisement)) { throw new Exception("خطایی در ویرایش آگهی وجود دارد"); } var str = stringWriter.ToString(); return(System.Net.WebUtility.HtmlDecode(str)); } return("No Advertisment Mached With Your Keyword"); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public string GetHtml4Position(string keyword) { try { var sectionPosition = new AdvertisementSectionPositionBO().GetByKeyWord(this.ConnectionHandler, keyword); //انتخاب تبلیغ های معتبر در موقعیت //ریختن لیست در صف if (sectionPosition != null) { AdvertisementQueue.Queue = AdvertisementQueue.GetViewAbleAdvertisements(sectionPosition); var advs = new List <Advertisement>(); for (var index = 1; index <= sectionPosition.AdsShowCount; index++) { var obj = AdvertisementQueue.POP(sectionPosition); if (obj != null) { advs.Add(obj); } if (AdvertisementQueue.Queue.Count == 0) { break; } } var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.AddAttribute("src", "/Areas/Advertisements/Content/Advertisment.js"); writer.AddAttribute("Type", "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.RenderEndTag(); if (!sectionPosition.Orientation) { writer.AddAttribute("id", sectionPosition.KeyWord); writer.AddAttribute("align", "center"); writer.RenderBeginTag(HtmlTextWriterTag.Table); writer.RenderBeginTag(HtmlTextWriterTag.Tr); } foreach (var advertisement in advs) { writer.AddAttribute("onclick", string.Format("OnAdvClick('{0}');", advertisement.Id)); if (!sectionPosition.Orientation) { writer.AddAttribute("Id", (advs.IndexOf(advertisement) + 1).ToString()); writer.AddAttribute("width", advertisement.width.ToString()); writer.AddAttribute("align", "center"); writer.RenderBeginTag(HtmlTextWriterTag.Td); } else { writer.AddAttribute("Id", (advs.IndexOf(advertisement) + 1).ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Div); } if (advertisement.Timeout > 0) { writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.WriteEncodedText(string.Format("SetInterval('{0}',{1},'{2}');", (advs.IndexOf(advertisement) + 1), advertisement.Timeout, keyword)); writer.RenderEndTag(); } //تولید قالب تبلیغات بر حسب نوع آن switch (advertisement.AdvertisementType.Type) { case "Text": #region TEXT if (string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.WriteEncodedText(advertisement.Text); } else { writer.AddAttribute("href", advertisement.NavigateUrl); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.WriteEncodedText(Utils.ConvertHtmlToString(advertisement.Text)); writer.RenderEndTag(); } break; #endregion case "SWF": #region FLASH writer.AddAttribute("codeBase", "https://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7.0.19.0"); writer.AddAttribute("classid", "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"); writer.AddAttribute("width", advertisement.width.ToString()); writer.AddAttribute("height", advertisement.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Object); writer.AddAttribute("NAME", "Movie"); writer.AddAttribute("VALUE", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.RenderBeginTag(HtmlTextWriterTag.Param); writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.AddAttribute("quality", "high"); writer.AddAttribute("wmode", "opaque"); writer.AddAttribute("pluginspage", "https://www.macromedia.com/go/getflashplayer"); writer.AddAttribute("type", "application/x-shockwave-flash"); writer.AddAttribute("width", advertisement.width.ToString()); writer.AddAttribute("height", advertisement.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Embed); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); break; #endregion case "Html": #region HTML writer.Write(Utils.ConvertHtmlToString(advertisement.Text)); break; #endregion case "Image": #region IMAGE if (!string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.AddAttribute("href", advertisement.NavigateUrl); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag(HtmlTextWriterTag.A); } writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + advertisement.FileId); writer.AddAttribute("border", "0"); writer.AddAttribute("height", advertisement.Height.ToString()); writer.AddAttribute("width", advertisement.width.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); if (!string.IsNullOrEmpty(advertisement.NavigateUrl)) { writer.RenderEndTag(); } break; #endregion } //یک واحد به تعداد نمایش تبلیغ اضافه می شود advertisement.VisitCount++; writer.RenderEndTag(); if (!new AdvertisementBO().Update(this.ConnectionHandler, advertisement)) { throw new Exception("خطایی در ویرایش آگهی وجود دارد"); } } if (!sectionPosition.Orientation) { writer.RenderEndTag(); writer.RenderEndTag(); } var str = stringWriter.ToString(); return(System.Net.WebUtility.HtmlDecode(str)); } return("No Advertisment Mached With Your Keyword"); } catch (KnownException ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } catch (Exception ex) { Log.Save(ex.Message, LogType.ApplicationError, ex.Source, ex.StackTrace); throw new KnownException(ex.Message, ex); } }
public string GetThemeResourceHtml(Guid themeId, string culture) { try { var str = new StringWriter(); var html32TextWriter = new Html32TextWriter(str); var byFilter = new ResourceBO().OrderBy(this.ConnectionHandler, x => x.Order, x => x.ThemeId == themeId && x.LanuageId == culture ); foreach (var resource in byFilter) { switch ((Enums.ResourceType)resource.Type) { case Enums.ResourceType.JSFile: if (resource.FileId == null) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Src, FileManagerContants.FileHandlerRoot + resource.FileId); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Script); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.CssFile: if (resource.FileId == null) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Href, FileManagerContants.FileHandlerRoot + resource.FileId); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Link); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.JSFunction: if (string.IsNullOrEmpty(resource.Text)) { continue; } html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type, "text/javascript"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style); html32TextWriter.Write(resource.Text); html32TextWriter.RenderEndTag(); break; case Enums.ResourceType.Style: if (string.IsNullOrEmpty(resource.Text)) { continue; } html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Style); html32TextWriter.Write(resource.Text); html32TextWriter.RenderEndTag(); break; } } return(str.ToString()); } catch (KnownException knownException) { throw new KnownException(knownException.Message, knownException); } catch (Exception ex) { throw new KnownException(ex.Message, ex); } }
public void writeABCInfo() { _doc.Write(@"<p> This record has been submitted to the ABC.</P>" ); }
/// <summary> /// Render the widget to current response output. /// </summary> /// <param name="writer"></param> public override void Render(HtmlTextWriter writer) { var locale = App.Get().Context.Locale; if (!string.IsNullOrEmpty(locale)) { App.Get().SetCulture(locale); } bool isPreviewMode = false; Dictionary <string, PropertyDescriptor> propertyDescriptors = null; Dictionary <string, object> userdata = new Dictionary <string, object>(); var bag = Html.ViewContext.Controller.ViewBag; if (bag != null) { if (bag.PropertyDescriptors != null) { propertyDescriptors = bag.PropertyDescriptors as Dictionary <string, PropertyDescriptor>; if (propertyDescriptors != null) { foreach (var key in propertyDescriptors.Keys) { userdata.Add(key, propertyDescriptors[key].Value); } } } if (bag.IsPreview != null) { isPreviewMode = bag.IsPreview; } Model = bag.WidgetInstance; } var widgetHelper = new WidgetHelper() { Model = Model, UserPreferences = userdata, PropertyDescriptors = propertyDescriptors }; if (isPreviewMode) { if (!PreviewTemplate.IsEmpty) { PreviewTemplate.WriteTo(widgetHelper, writer); } else { if (!ContentTemplate.IsEmpty) { ContentTemplate.WriteTo(widgetHelper, writer); } } } else { if (IsDesignMode) { if (userdata.Count > 0 && this.Model.WidgetDescriptor.WidgetType == 1) { var urlhelper = new UrlHelper(Request.RequestContext); writer.WriteBeginTag("form"); writer.WriteAttribute("class", "d-widget-prefs d-tran-fast d-form"); writer.WriteAttribute("data-ajax", "true"); writer.WriteAttribute("data-ajax-url", urlhelper.Content("~/api/" + AppModel.Get().Context.Website + "/widgets/apply")); writer.WriteAttribute("data-ajax-method", "post"); //writer.WriteAttribute("data-ajax-begin", "$.loading()"); writer.WriteAttribute("data-ajax-success", "$('#widget_" + this.Model.ID.ToString() + "').widget('refresh');" + (AutoSave ? "" : "$.closePanels();")); if (this.HideUserPreferences) { writer.WriteAttribute("data-hidden", "true"); } if (this.AutoSave) { writer.WriteAttribute("data-auto-save", "true"); writer.WriteAttribute("onchange", "$(this).submit();"); } // writer.WriteAttribute("data-allow-pop", "false"); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteBeginTag("input"); writer.WriteAttribute("type", "hidden"); writer.WriteAttribute("name", "id"); writer.WriteAttribute("value", Model.ID.ToString()); writer.Write(HtmlTextWriter.SelfClosingTagEnd); if (!UserPreferencesTemplate.IsEmpty) { UserPreferencesTemplate.WriteTo(widgetHelper, writer); } else { foreach (var key in propertyDescriptors.Keys) { if (!propertyDescriptors[key].IsReadonly) { RenderPropertyControl(writer, widgetHelper, propertyDescriptors[key]); } } } writer.WriteEndTag("form"); } if (!DesignTemplate.IsEmpty) { DesignTemplate.WriteTo(widgetHelper, writer); } else if (!ContentTemplate.IsEmpty) { ContentTemplate.WriteTo(widgetHelper, writer); } writer.Write("<script type=\"text/javascript\">$(function(){ $('#widget_" + this.Model.ID.ToString() + "').taoUI(); });</script>"); //writer.Write("<script type=\"text/javascript\">$(function(){ $('#widget_" + this.Model.ID.ToString() + "').unobtrusive_ajax().taoUI(); });</script>"); } else { if (Model.Cached) { //Render cachable widget eg:Html widget var cachedHtml = ""; var cachedKey = "widget" + Model.ID.ToString() + "_caching_html"; if (Context.Cache[cachedKey] != null) { cachedHtml = Context.Cache[cachedKey].ToString(); } else { var cachedBuilder = new StringBuilder(); using (var cachedTextWriter = new System.IO.StringWriter(cachedBuilder)) { using (var cachedWriter = new Html32TextWriter(cachedTextWriter)) { if (!ContentTemplate.IsEmpty) { ContentTemplate.WriteTo(widgetHelper, cachedWriter); } if (!HeaderTemplate.IsEmpty && Model.ShowHeader) { cachedWriter.Write("<div id=\"widget_" + this.Model.ID.ToString() + "_header_holder\" style=\"display:none;\">"); HeaderTemplate.WriteTo(widgetHelper, cachedWriter); cachedWriter.Write("</div>"); cachedWriter.Write("<script type=\"text/javascript\">$(function(){ if ($('#widget_" + this.Model.ID.ToString() + "').find('.d-widget-header').length) { $('#widget_" + this.Model.ID.ToString() + "').find('.d-widget-header').empty().append($('#widget_" + this.Model.ID.ToString() + "_header_holder').children());$('#widget_" + this.Model.ID.ToString() + "_header_holder').remove(); } });</script>"); } } } cachedHtml = cachedBuilder.ToString(); Context.Cache.Add(cachedKey, cachedHtml, null, DateTime.Now.AddMinutes(5), System.Web.Caching.Cache.NoSlidingExpiration, System.Web.Caching.CacheItemPriority.Default, null); } writer.Write(cachedHtml); } else { if (!ContentTemplate.IsEmpty) { ContentTemplate.WriteTo(widgetHelper, writer); } if (!HeaderTemplate.IsEmpty && Model.ShowHeader) { writer.Write("<div id=\"widget_" + this.Model.ID.ToString() + "_header_holder\" style=\"display:none;\">"); HeaderTemplate.WriteTo(widgetHelper, writer); writer.Write("</div>"); writer.Write("<script type=\"text/javascript\">$(function(){ if ($('#widget_" + this.Model.ID.ToString() + "').find('.d-widget-header').length) { $('#widget_" + this.Model.ID.ToString() + "').find('.d-widget-header').empty().append($('#widget_" + this.Model.ID.ToString() + "_header_holder').children());$('#widget_" + this.Model.ID.ToString() + "_header_holder').remove(); } });</script>"); } } } } //writer.Write(System.Web.Optimization.Scripts.Render("~/bundles/jqueryval")); //writer.Write(html.StartupScripts().ToString()); }
private static void RenderChildren(Html32TextWriter writer, ContentListDecorator list, IEnumerable <ContentDataItem> items, ContentDataItem current) { var app = App.Get(); var fieldName = list.GetDefaultTitleField().Name; var Url = DNA.Utility.UrlUtility.CreateUrlHelper(); foreach (var item in items) { var itemWrapper = app.Wrap(item); writer.WriteBeginTag("li"); var _class = "d-node"; var children = itemWrapper.Children(); var childrenCount = children.Count(); if (childrenCount > 0) { _class += " d-node-hasChildren"; } //writer.WriteAttribute("class", "d-node d-node-hasChildren"); var isInPath = false; if (current != null && !string.IsNullOrEmpty(current.Path) && !string.IsNullOrEmpty(item.Path) && current.Path.StartsWith(item.Path)) { isInPath = true; if (childrenCount > 0) { writer.WriteAttribute("data-expanded", "true"); } } writer.WriteAttribute("data-id", itemWrapper.ID.ToString()); if (current != null && itemWrapper.ID.Equals(current.ID)) { writer.WriteAttribute("data-selected", "true"); } if (itemWrapper.ParentItemID != Guid.Empty) { writer.WriteAttribute("data-parentid", itemWrapper.ParentItemID.ToString()); } if (childrenCount > 0) { if (!isInPath) { var urlformat = "~/api/contents/items?name={0}&slug={1}&parentId={2}"; var popupUrl = Url.Content(string.Format(urlformat, list.Name, list.Views.Default.Name, itemWrapper.ID.ToString())); writer.WriteAttribute("data-popupurl", popupUrl); } } writer.WriteAttribute("class", _class); writer.Write(Html32TextWriter.TagRightChar); writer.WriteBeginTag("a"); writer.WriteAttribute("href", itemWrapper.UrlComponent); writer.Write(Html32TextWriter.TagRightChar); writer.Write(itemWrapper.Value(fieldName).Raw); writer.WriteEndTag("a"); if (childrenCount > 0) { if (isInPath) { writer.WriteFullBeginTag("ul"); RenderChildren(writer, list, children, current); writer.WriteEndTag("ul"); } } writer.WriteEndTag("li"); } }
/// <summary> /// Writes the header of the webpage. The header contains references to bootstrap, a favoicon and some stylefile. /// </summary> /// <param name='htw'> /// A <see cref="Html32TextWriter"/> to write the content to. /// </param> private void WriteHeader(Html32TextWriter htw) { htw.RenderBeginTag(HtmlTextWriterTag.Title); { htw.Write(this.device.Navigationbar.Name); } htw.RenderEndTag(); htw.AddAttribute(HtmlTextWriterAttribute.Name, "generator"); htw.AddAttribute(HtmlTextWriterAttribute.Content, ProgramManager.ProgramNameVersion); htw.RenderBeginTag(HtmlTextWriterTag.Meta); {} htw.RenderEndTag(); htw.WriteLine(); htw.AddAttribute(HtmlTextWriterAttribute.Name, "viewport"); htw.AddAttribute(HtmlTextWriterAttribute.Content, "width=device-width, initial-scale=1.0"); htw.RenderBeginTag(HtmlTextWriterTag.Meta); {} htw.RenderEndTag(); htw.WriteLine(); htw.AddAttribute(HtmlTextWriterAttribute.Href, "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"); htw.AddAttribute(HtmlTextWriterAttribute.Rel, "stylesheet"); htw.RenderBeginTag(HtmlTextWriterTag.Link); {} htw.RenderEndTag(); htw.WriteLine(); htw.AddAttribute(HtmlTextWriterAttribute.Href, IconName); htw.AddAttribute(HtmlTextWriterAttribute.Rel, "icon"); htw.AddAttribute(HtmlTextWriterAttribute.Type, "image/x-icon"); htw.RenderBeginTag(HtmlTextWriterTag.Link); {} htw.RenderEndTag(); htw.WriteLine(); htw.RenderBeginTag(HtmlTextWriterTag.Style); { htw.Write("body {min-height: 2000px;padding-top: 70px;}"); } htw.RenderEndTag(); htw.AddAttribute("language", "javascript"); htw.RenderBeginTag(HtmlTextWriterTag.Script); { htw.WriteLine("function genericAjax (source, target) {"); htw.WriteLine(" var xmlhttp;"); htw.WriteLine(" if (window.XMLHttpRequest) {"); htw.WriteLine(" xmlhttp=new XMLHttpRequest();"); htw.WriteLine(" } else {"); htw.WriteLine(" xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");"); htw.WriteLine(" }"); htw.WriteLine(" xmlhttp.onreadystatechange=function() {"); htw.WriteLine(" if (xmlhttp.readyState==4) {"); htw.WriteLine(" if(xmlhttp.status==200) {"); htw.WriteLine(" document.getElementById(target).innerHTML=xmlhttp.responseText;"); htw.WriteLine(" } else {"); htw.WriteLine(" document.getElementById(target).innerHTML=\"<div class='alert alert-warning'><strong>Warning:</strong> something went wrong during an AJAX call. Error code: \"+xmlhttp.status+\", Source: \"+source+\".</div>\";"); htw.WriteLine(" }"); htw.WriteLine(" }"); htw.WriteLine(" }"); htw.WriteLine(" xmlhttp.open(\"GET\",source,true);"); htw.WriteLine(" xmlhttp.send();"); htw.WriteLine("}"); } htw.RenderEndTag(); htw.WriteLine(); }
public void WriteTo(Html32TextWriter writer, List <string> classNames, ICssClassMapper classMapper) { writer.Write(')'); }
/// <summary> /// Render the webpage onto the give specified engine. /// </summary> /// <param name='serverFolder'> /// The root of the folder of the web server. /// </param> /// <param name='engine'> /// The given specified engine. /// </param> /// <param name='writer'> /// The html writer to write content to. /// </param> public override void Render(string serverFolder, HttpEngine engine, Html32TextWriter writer) { writer.Write(this.fragment); }