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(); }
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(); }
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); }
/// <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(); }
/// <summary> /// Writes references of some javascript libraries to the given <see cref="Html32TextWriter"/> to let the bootstrap work. /// </summary> /// <param name='htw'> /// The <see cref="Html32TextWriter"/> to write the content to. /// </param> private void WriteJavascript(Html32TextWriter htw) { htw.AddAttribute(HtmlTextWriterAttribute.Src, "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"); htw.RenderBeginTag(HtmlTextWriterTag.Script); htw.RenderEndTag(); htw.WriteLine(); htw.AddAttribute(HtmlTextWriterAttribute.Src, "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"); htw.RenderBeginTag(HtmlTextWriterTag.Script); {} htw.RenderEndTag(); }
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()); }
/// <summary> /// Writes the body of the given <see cref="IWebPage"/> to the <see cref="Html32TextWriter"/>. /// </summary> /// <param name='htw'> /// The <see cref="Html32TextWriter"/> to write the content to. /// </param> /// <param name='webpage'> /// The <see cref="IWebPage"/> to write to the <see cref="Html32TextWriter"/>. /// </param> private void WriteBody(Html32TextWriter htw, IWebPage webpage) { this.WriteMasthead(htw, webpage); htw.AddAttribute(HtmlTextWriterAttribute.Class, "container"); htw.RenderBeginTag(HtmlTextWriterTag.Div); htw.RenderBeginTag(HtmlTextWriterTag.Hr); htw.RenderEndTag(); webpage.Render(this.device.Manager.ServerFolder, this, htw); this.WriteFooter(htw); htw.RenderEndTag(); }
/// <summary> /// Converts the set of <see cref="IdpGie.Shapes.IShape"/> by converting it into a readable format. /// </summary> public override void Process() { using (StreamReader inputStream = new StreamReader(client.GetStream())) { String request = inputStream.ReadLine(), line; string[] tokens = request.Split(' '); if (tokens.Length != 3) { throw new Exception("invalid http request line"); } StringBuilder rest = new StringBuilder(); do { line = inputStream.ReadLine(); rest.AppendLine(line); } while(line != string.Empty && line != null); //string http_url = tokens [1]; string http_filename = tokens [1]; Console.WriteLine("\"{0}\"", http_filename); if (http_filename == "/" + IconName) { this.device.Navigationbar.FavIcon.RenderIcon(this.device.Manager.ServerFolder, this, client.GetStream()); } else { bool border; IWebPage wp = this.device.Navigationbar.GetPage(http_filename.Substring(0x01), out border); using (StreamWriter sw = new StreamWriter(client.GetStream())) { using (Html32TextWriter tw = new Html32TextWriter(sw)) { if (border) { tw.WriteLine("<!DOCTYPE html>"); tw.RenderBeginTag(HtmlTextWriterTag.Html); tw.RenderBeginTag(HtmlTextWriterTag.Head); this.WriteHeader(tw); tw.RenderEndTag(); tw.RenderBeginTag(HtmlTextWriterTag.Body); this.WriteBody(tw, wp); this.WriteJavascript(tw); tw.RenderEndTag(); tw.RenderEndTag(); } else { wp.Render(this.device.Manager.ServerFolder, this, tw); } } } } } }
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()); }
/// <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) { string landingName = this.LandingName; writer.AddAttribute(HtmlTextWriterAttribute.Id, landingName); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderEndTag(); if (this.QueryPage != null) { writer.RenderBeginTag(HtmlTextWriterTag.Script); writer.WriteLine("genericAjax (\"{0}\", \"{1}\");", this.QueryPage.Href, landingName); writer.RenderEndTag(); } }
public static void WriteFormId(this HtmlHelper htmlHelper, bool modal = true) { try { if (htmlHelper.ViewContext == null || htmlHelper.ViewContext.ViewBag == null) { return; } var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); if (htmlHelper.ViewContext.ViewBag.FormId != null) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "RadynFormId"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "RadynFormId"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute("ModalMode", modal.ToString()); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewBag.FormId); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } htmlHelper.ViewContext.Writer.Write(stringWriter); } catch { } }
private static void WriteLabel <TModel>(HtmlHelper helper, TModel obj, int width, int height, string name) where TModel : class { var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); var objectkeyskey = obj.GetCultureKeys(); if (!objectkeyskey.Keys.Contains(name)) { return; } var content = LanguageContent(obj, name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id, "lbl" + name); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value, content.Value); //html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Style, "width:" + width + "px;" + "height:" + height + "px;"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Class, "item"); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); html32TextWriter.InnerWriter.Write(content.Value); html32TextWriter.RenderEndTag(); helper.ViewContext.Writer.Write(stringWriter); }
private static void GeneratorEvaluationControls(HtmlHelper helper, FormEvaluation formEvaluation) { if (formEvaluation == null) { return; } var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.AddAttribute(HtmlTextWriterAttribute.Class.ToString(), "fitper"); writer.RenderBeginTag(HtmlTextWriterTag.Div.ToString()); writer.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "FormId"); writer.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "FormId"); writer.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), formEvaluation.ControlId); writer.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); writer.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); writer.RenderEndTag(); foreach (Control controlvalueModel in formEvaluation.Controls) { controlvalueModel.Writer = writer; controlvalueModel.FormState = formEvaluation.FormState; if (formEvaluation.GetFormControl != null) { controlvalueModel.Value = formEvaluation.GetFormControl.ContainsKey(controlvalueModel.Id) ? formEvaluation.GetFormControl[controlvalueModel.Id] : null; } controlvalueModel.Generate(); writer.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "Order-" + controlvalueModel.Id); writer.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "Order-" + controlvalueModel.Id); writer.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), controlvalueModel.Order.ToString()); writer.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); writer.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); writer.RenderEndTag(); } writer.RenderEndTag(); var resourceScript = helper.ViewContext.GenerateResourceScript(); var format = resourceScript + stringWriter; helper.ViewContext.Writer.Write(format); }
public static void WriteReturnValuesHideId(this HtmlHelper htmlHelper) { try { if (htmlHelper.ViewContext == null || htmlHelper.ViewContext.ViewBag == null) { return; } var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); if (htmlHelper.ViewContext.ViewBag.fki != null) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "fki"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "fki"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewBag.fki); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewBag.fkd != null) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "fkd"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "fkd"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewBag.fkd); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewBag.fkb != null) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), "fkb"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), "fkb"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewBag.fkb); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } htmlHelper.ViewContext.Writer.Write(stringWriter); } catch { } }
/// <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(); }
public virtual void WriteXhtml(Html32TextWriter writer) { if (this.HtmlTag != null && this.HtmlTag != string.Empty) { foreach (KeyValueEntry kve in this.HtmlAttributes) { writer.AddAttribute(kve.Key, kve.Value); } writer.RenderBeginTag(this.HtmlTag); writer.RenderEndTag(); } }
private void Deny_Unrestricted(Html32TextWriter htw) { htw.ShouldPerformDivTableSubstitution = true; Assert.IsTrue(htw.ShouldPerformDivTableSubstitution, "ShouldPerformDivTableSubstitution"); htw.SupportsBold = true; Assert.IsTrue(htw.SupportsBold, "SupportsBold"); htw.SupportsItalic = true; Assert.IsTrue(htw.SupportsItalic, "SupportsItalic"); htw.RenderBeginTag(HtmlTextWriterTag.Table); htw.RenderBeginTag("<tr>"); htw.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 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()); }
/// <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) { this.Load(serverFolder); foreach (HtmlAttribute ha in this.node.Attributes) { writer.AddAttribute(ha.Name, ha.Value); } writer.RenderBeginTag(this.node.Name); if (this.pieces != null) { foreach (IWebPagePiece piece in this.pieces) { piece.Render(serverFolder, engine, writer); } } writer.RenderEndTag(); }
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(); }
public static void SearchRealtedHelp <TModel, TValue>(this HtmlHelper helper, TModel model, System.Linq.Expressions.Expression <Func <TModel, TValue> > value, string url = "/Help/Help/Search", int width = 800, int height = 600) where TModel : class { var s = value.Body.ToString(); var lastIndexOf = s.LastIndexOf("."); var id = s.Substring(lastIndexOf + 1, s.Length - lastIndexOf - 1); var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); helper.ViewContext.AddScript("/Scripts/Radyn/ModalWindows.js"); writer.AddAttribute("Type", "text"); writer.AddAttribute("readonly", "readonly"); writer.AddAttribute("name", "txt" + id); writer.AddAttribute("id", "txt" + id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { Guid eid; if (Guid.TryParse(val.ToString(), out eid)) { var help = HelpComponent.Instance.HelpFacade.Get(eid); if (help != null) { writer.AddAttribute("value", help.DefaultTitle); } } } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("Type", "hidden"); writer.AddAttribute("name", id); writer.AddAttribute("id", id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { writer.AddAttribute("value", val.ToString()); } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("class", "m-btn waves-blue i-search icon-btn"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute("onclick", string.Format("ShowModalWithReturnValue('{0}','" + id + "','txt" + id + "');", url)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); writer.AddAttribute("class", "m-btn waves-blue i-eraser icon-btn"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute("onclick", string.Format("document.getElementById('txt" + id + "').value='';document.getElementById('" + id + "').value='';", url, width, height)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
public static void PrepareModel(this HtmlHelper htmlHelper, Type type, string cutomePrefixname) { try { if (htmlHelper.ViewContext == null || htmlHelper.ViewContext.ViewData == null) { return; } var stringWriter = new StringWriter(); var html32TextWriter = new Html32TextWriter(stringWriter); var keyName = BaseControllerUtility.GetModelKeyName(type, cutomePrefixname); var pagModeKeyName = BaseControllerUtility.GetPagModeKeyName(type, cutomePrefixname); var modifyBehaviorStausKeyName = BaseControllerUtility.GetModifyBehaviorStausKeyName(type, cutomePrefixname); var cultureKeyName = BaseControllerUtility.GetCultureKeyName(type, cutomePrefixname); var updateFormDataKeyName = BaseControllerUtility.GetUpdateFormDataKeyName(type, cutomePrefixname); var controllerStatusKeyName = BaseControllerUtility.GetControllerStatusKeyName(type, cutomePrefixname); if (htmlHelper.ViewContext.ViewData.ContainsKey(keyName)) { var split = Radyn.Utility.Serialize.JsonDeserialize <List <KeyValuePair <string, object> > >(htmlHelper.ViewContext.ViewData[keyName].ToString()); foreach (var pair in split) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), pair.Key); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), pair.Key); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), pair.Value != null ? pair.Value.ToString() : null); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } } if (htmlHelper.ViewContext.ViewData.ContainsKey(pagModeKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), pagModeKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), pagModeKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[pagModeKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(modifyBehaviorStausKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), modifyBehaviorStausKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), modifyBehaviorStausKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[modifyBehaviorStausKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(cultureKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), cultureKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), cultureKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[cultureKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(updateFormDataKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), updateFormDataKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), updateFormDataKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[updateFormDataKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } if (htmlHelper.ViewContext.ViewData.ContainsKey(controllerStatusKeyName)) { html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Id.ToString(), controllerStatusKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Name.ToString(), controllerStatusKeyName); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Type.ToString(), "hidden"); html32TextWriter.AddAttribute(HtmlTextWriterAttribute.Value.ToString(), htmlHelper.ViewContext.ViewData[controllerStatusKeyName].ToString()); html32TextWriter.RenderBeginTag(HtmlTextWriterTag.Input.ToString()); html32TextWriter.RenderEndTag(); } htmlHelper.ViewContext.Writer.Write(stringWriter); } catch { } }
public static void SearchParentInMenuTree <TModel, TValue>(this HtmlHelper helper, TModel model, System.Linq.Expressions.Expression <Func <TModel, TValue> > value, string url = "/ContentManager/Menu/LookUpMenu", int width = 400, int height = 300) where TModel : class { var s = value.Body.ToString(); var lastIndexOf = s.LastIndexOf("."); var id = s.Substring(lastIndexOf + 1, s.Length - lastIndexOf - 1); if (url == null) { url = "/ContentManager/Menu/LookUpMenu"; } var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); writer.AddAttribute("Type", "text"); writer.AddAttribute("readonly", "readonly"); writer.AddAttribute("name", "txt" + id); writer.AddAttribute("id", "txt" + id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { Guid eid; if (Guid.TryParse(val.ToString(), out eid)) { var menu = ContentManagerComponent.Instance.MenuFacade.Get(eid); if (menu != null) { writer.AddAttribute("value", menu.Text); } } } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("Type", "hidden"); writer.AddAttribute("name", id); writer.AddAttribute("id", id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { writer.AddAttribute("value", val.ToString()); } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("class", "m-btn waves-blue i-search icon-btn"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); //writer.AddAttribute("Type", "a"); writer.AddAttribute("src", "/Content/Images/search_button.png"); writer.AddAttribute("Id", "SearchBtn"); writer.AddAttribute("onclick", string.Format("ShowModalWithReturnValue('{0}','" + id + "','txt" + id + "');", url)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); writer.AddAttribute("class", "m-btn waves-blue i-eraser icon-btn"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.AddAttribute("src", "/Content/Images/eraser.png"); writer.AddAttribute("Id", "EraseBtn"); writer.AddAttribute("onclick", string.Format("document.getElementById('txt" + id + "').value='';document.getElementById('" + id + "').value='';", url, width, height)); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
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 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 string Buid() { var fileType = this.DetectFileType(); var sw = new StringWriter(); var writer = new Html32TextWriter(sw); var query = ""; if (FixSize) { query = "w=" + this.Width + "&h=" + this.Height; } writer.AddAttribute("id", this.Name); writer.AddAttribute("name", this.Name); writer.AddAttribute("type", "hidden"); writer.AddAttribute("value", this.Id.ToString()); writer.RenderBeginTag("input"); writer.RenderEndTag(); if (DeleteButtonVisible) { var str = "document.getElementById('" + this.Name + "').value='" + null + "';" + "$('#Delete-" + this.Name + "').hide();" + "$('#atag-" + this.Name + "').hide();" + "$('#Filetag-" + this.Name + "').hide();"; writer.AddAttribute("id", "Delete-" + this.Name); writer.AddAttribute("name", "Delete-" + this.Name); writer.AddAttribute("type", "button"); writer.AddAttribute("value", Resources.FileManager.DeleteFile); writer.AddAttribute("onclick", str); writer.AddAttribute("style", "width:80px;"); writer.RenderBeginTag("input"); writer.RenderEndTag(); } var file = FileManagerComponent.Instance.FileFacade.Get(Id); if (Download) { writer.AddAttribute("Id", "atag-" + this.Name); writer.AddAttribute("href", FileManagerContants.FileHandlerRoot + this.Id + "?dl=true&" + query); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag("a"); if (file != null) { writer.WriteEncodedText(file.FullName); } writer.RenderEndTag(); } else { switch (fileType) { case FileType.Image: writer.AddAttribute("Id", "Filetag-" + this.Name); writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + this.Id + (string.IsNullOrEmpty(query) ? "" : "?") + query); if (this.Height.HasValue) { writer.AddAttribute("height", this.Height.Value.ToString()); } if (this.Width.HasValue) { writer.AddAttribute("width", this.Width.Value.ToString()); } if (!string.IsNullOrEmpty(this.Style)) { writer.AddAttribute("style", this.Style); } if (!string.IsNullOrEmpty(this.Title)) { writer.AddAttribute("title", this.Title); } if (!string.IsNullOrEmpty(this.Alt)) { writer.AddAttribute("alt", this.Alt); } if (this.OtherAttribute != null) { foreach (var property in this.OtherAttribute.GetType().GetProperties()) { writer.AddAttribute(property.Name, property.GetValue(this.OtherAttribute, null).ToString()); } } writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); break; case FileType.SWF: 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", this.Width.ToString()); writer.AddAttribute("height", this.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Object); writer.AddAttribute("NAME", "Movie"); writer.AddAttribute("VALUE", FileManagerContants.FileHandlerRoot + this.Id); writer.RenderBeginTag(HtmlTextWriterTag.Param); writer.AddAttribute("src", FileManagerContants.FileHandlerRoot + this.Id); 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", this.Width.ToString()); writer.AddAttribute("height", this.Height.ToString()); writer.RenderBeginTag(HtmlTextWriterTag.Embed); writer.RenderEndTag(); writer.RenderEndTag(); writer.RenderEndTag(); break; case FileType.Unkown: writer.AddAttribute("Id", "atag-" + this.Name); writer.AddAttribute("href", FileManagerContants.FileHandlerRoot + this.Id + "?dl=true&" + query); writer.AddAttribute("target", "_blank"); writer.RenderBeginTag("a"); if (file != null) { writer.WriteEncodedText(file.FullName); } writer.RenderEndTag(); break; } } return(sw.ToString()); }
public static void SearchEnterpriseNode <TModel, TValue>(this HtmlHelper helper, TModel model, System.Linq.Expressions.Expression <Func <TModel, TValue> > value, string enterprisetype = "n", string url = "/EnterPriseNode/EnterPriseNode/Search", int width = 800, int height = 600) where TModel : class { var s = value.Body.ToString(); var lastIndexOf = s.LastIndexOf("."); var id = s.Substring(lastIndexOf + 1, s.Length - lastIndexOf - 1); var stringWriter = new StringWriter(); var writer = new Html32TextWriter(stringWriter); helper.ViewContext.AddScript("/Scripts/Radyn/ModalWindows.js"); writer.AddAttribute("Type", "text"); writer.AddAttribute("readonly", "readonly"); writer.AddAttribute("name", "txt" + id); writer.AddAttribute("id", "txt" + id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { Guid eid; if (Guid.TryParse(val.ToString(), out eid)) { var enterpriseNode = EnterpriseNodeComponent.Instance.EnterpriseNodeFacade.Get(eid); if (enterpriseNode != null) { writer.AddAttribute("value", enterpriseNode.Title()); } } } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); writer.AddAttribute("Type", "hidden"); writer.AddAttribute("name", id); writer.AddAttribute("id", id); if (model != null) { var val = model.GetType().GetProperty(id).GetValue(model, null); if (val != null) { writer.AddAttribute("value", val.ToString()); } } writer.RenderBeginTag(HtmlTextWriterTag.Input); writer.RenderEndTag(); //writer.AddAttribute("Type", "image"); writer.AddAttribute("src", "/Content/Images/search_button.png"); writer.AddAttribute("style", "border-style: groove; border-width: thin;"); writer.AddAttribute("onclick", string.Format("ShowModalWithReturnValue('{0}','" + id + "','txt" + id + "');", url + "?type=" + enterprisetype)); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); //writer.AddAttribute("Type", "image"); writer.AddAttribute("src", "/Content/Images/eraser.png"); writer.AddAttribute("style", "border-style: groove; border-width: thin;"); writer.AddAttribute("onclick", string.Format("document.getElementById('txt" + id + "').value='';document.getElementById('" + id + "').value='';", url, width, height)); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); var resourceScript = helper.ViewContext.GenerateResourceScript(); helper.ViewContext.Writer.Write(resourceScript + stringWriter); }
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); } }