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


C# HtmlGenericControl.RenderControl方法代码示例

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


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

示例1: ASPXToPDF

        public void ASPXToPDF(HtmlGenericControl objhtml)
        {
            string fileName = "AsignacionFolios.pdf";
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.Clear();

            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            objhtml.RenderControl(hw);

            StringReader sr = new StringReader(sw.ToString());

            Document pdfDoc = new Document(PageSize.A2, 5f, 5f, 5f, 5f);
            HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
            PdfWriter.GetInstance(pdfDoc, HttpContext.Current.Response.OutputStream);
            pdfDoc.Open();
            htmlparser.Parse(sr);
            pdfDoc.Close();

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.Write(pdfDoc);
            HttpContext.Current.Response.End();
        }
开发者ID:FranciscoMontelongo,项目名称:Basica-Prom-Supervisores-Asigna15,代码行数:25,代码来源:PDFExpress.cs

示例2: Render

        protected override void Render(HtmlTextWriter writer)
        {
            this.InputJsonId = this.JsonId;
            this.InputElementTagName = "input";
            if (this.RenderName)
            {
                HtmlGenericControl div = new HtmlGenericControl();
                div.TagName = "div";
                //div.Style.Add("display", "inline-block");

                div.Attributes.Add("class", this.NameCssClass);

                div.Controls.Add(new LiteralControl(this.Name));
                div.RenderControl(writer);
            }
            if (this.CanEdit)
                base.Render(writer);
            else
            {
                string displayValue = !string.IsNullOrEmpty(this.Value) ? this.Value : this.Text;
                this.controlToRender.TagName = "span";
                if (!string.IsNullOrEmpty(this.CssClass))
                    this.controlToRender.Attributes.Add("class", this.CssClass);
                this.controlToRender.Controls.Add(new LiteralControl(displayValue));
                this.controlToRender.RenderControl(writer);

                JsonHiddenInput hiddenInput = new JsonHiddenInput();
                hiddenInput.JsonId = this.JsonId;
                hiddenInput.Value = displayValue;
                hiddenInput.RenderControl(writer);
            }
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:32,代码来源:JsonConditionalTextBox.cs

示例3: RenderContents

 protected override void RenderContents(HtmlTextWriter output)
 {
     HtmlGenericControl ctrl = new HtmlGenericControl("PRE");
     ctrl.Attributes["class"] = CssClass;
     ctrl.InnerText = Text;
     ctrl.RenderControl(output);
 }
开发者ID:m-berkani,项目名称:ClearCanvas,代码行数:7,代码来源:PreformattedLabel.cs

示例4: Render

        protected override void Render(HtmlTextWriter writer)
        {
            if (this.RenderName)
            {
                controlToRender.Attributes.Add("class", this.CssClass);
                HtmlGenericControl div = new HtmlGenericControl();
                div.TagName = "div";
                div.Style.Add("display", "inline-block");

                div.Attributes.Add("class", this.NameCssClass);

                div.Controls.Add(new LiteralControl(Name));
                div.RenderControl(writer);
            }
            if (this.CanEdit)
                base.Render(writer);
            else
            {
                this.InputElementTagName = "input";
                JsonHiddenInput hiddenInput = new JsonHiddenInput();
                hiddenInput.JsonId = this.JsonId;
                hiddenInput.Value = this.Value;
                hiddenInput.RenderControl(writer);

                this.controlToRender.Controls.Clear();
                this.controlToRender.TagName = "span";
                this.controlToRender.Attributes.Add("class", this.CssClass);
                this.controlToRender.Controls.Add(new LiteralControl(this.Text));
                this.controlToRender.RenderControl(writer);

            }
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:32,代码来源:JsonConditionalDropDown.cs

示例5: GetHtml

 public static string GetHtml(HtmlGenericControl control)
 {
     StringBuilder s = new StringBuilder();
     HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(s));
     control.RenderControl(tw);
     tw.Flush();
     return s.ToString();
 }
开发者ID:dblock,项目名称:sncore,代码行数:8,代码来源:HtmlGenericExtractor.cs

示例6: RenderListEntry

        protected void RenderListEntry(String title, HtmlGenericControl value)
        {
            Writer.RenderBeginTag(HtmlTextWriterTag.Dt);
            Writer.Write(title);
            Writer.RenderEndTag();

            value.RenderControl(Writer);
        }
开发者ID:davidajulio,项目名称:claims,代码行数:8,代码来源:BaseInfoControl.cs

示例7: GoogleMap

        private static MvcHtmlString GoogleMap(HtmlHelper helper, string id, Models.Map map, bool editor)
        {
            StringBuilder sbControlHtml = new StringBuilder();
            using (StringWriter stringWriter = new StringWriter())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                {
                    //Generate container div control
                    HtmlGenericControl divWrapperControl = new HtmlGenericControl("div");
                    HtmlGenericControl divMapControl = new HtmlGenericControl("div");
                    divMapControl.Attributes.Add("class", "map-container");
                    divMapControl.Attributes.Add("id", string.Format("map-{0}", id));
                    if (map.height > 0 || map.width > 0)
                    {
                        string widthStyle = "width:{0}px;";
                        if (map.width > 0)
                        {
                            widthStyle = string.Format(widthStyle, map.width);
                        }
                        else
                        {
                            widthStyle = string.Empty;
                        }

                        string heightStyle = "height:{0}px;";
                        if (map.height > 0)
                        {
                            heightStyle = string.Format(heightStyle, map.height);
                        }
                        else
                        {
                            heightStyle = string.Empty;
                        }

                        divMapControl.Attributes.Add("style", string.Concat(widthStyle, heightStyle));
                    }

                    divWrapperControl.Controls.Add(divMapControl);

                    //value input control
                    HtmlInputHidden hidden = new HtmlInputHidden();
                    HtmlInputHidden hiddenValueControl = new HtmlInputHidden();
                    hiddenValueControl.ID = id;
                    divWrapperControl.Controls.Add(hiddenValueControl);

                    HtmlGenericControl scriptControl = new HtmlGenericControl("script");
                    scriptControl.Attributes.Add("type", "text/javascript");
                    scriptControl.InnerHtml = string.Format(@"$(document).ready(function(){{
                                                    $('#map-{0}').GoogleMapEditor($.extend({{}},{1},{{dataChange:function(sender, data){{ $(sender.container).next().next().val(data); }}}}));}});", id, map.ToJsonString());
                    divWrapperControl.Controls.Add(scriptControl);
                    divWrapperControl.RenderControl(htmlWriter);
                    sbControlHtml.Append(stringWriter.ToString());
                    divWrapperControl.Dispose();
                }
            }
            return new MvcHtmlString(sbControlHtml.ToString());
        }
开发者ID:landsurveyorsunited,项目名称:MVC-GoogleMaps,代码行数:57,代码来源:HtmlHelpers.cs

示例8: ProcessRequest

        private void ProcessRequest(HttpContext context)
        {
            HtmlGenericControl html = new HtmlGenericControl("html");
            HtmlGenericControl body = new HtmlGenericControl("body");
            GridView grid = BuildPersonGridView();

            body.Controls.Add(grid);
            html.Controls.Add(body);

            TextWriter writer = context.Response.Output;
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
            html.RenderControl(htmlWriter);
        }
开发者ID:jglozano,项目名称:presentations,代码行数:13,代码来源:MainHandler.cs

示例9: IncludeJS

 /// <summary>
 /// Includes an html markup like <script type=text/css src=[YOUR_HREF]></script>
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="path"></param>
 /// <param name="includeVersionBasedOnLastModifiedDate">adding the query param "v" = [yyyyMMddHHmmss] based on file last modified date</param>
 /// <returns></returns>
 public static IHtmlString IncludeJS(this HtmlHelper htmlHelper, string path, bool includeVersionBasedOnLastModifiedDate = true)
 {
     string physicalPath = htmlHelper.ViewContext.HttpContext.Server.MapPath(path);
     var fileInfo = new FileInfo(physicalPath);
     if (!fileInfo.Exists) return new RawHtmlString(String.Empty);
     var lastModifiedDate = fileInfo.LastWriteTime;
     var sb = new StringBuilder();
     using (var textWriter = new StringWriter(sb))
     {
         using (var htmlWriter = new HtmlTextWriter(textWriter))
         {
             var htmlScript = new HtmlGenericControl("script");
             htmlScript.Attributes["type"] = "text/javascript";
             htmlScript.Attributes["src"] = String.Format("{0}?v={1:yyyyMMddHHmmss}", VirtualPathUtility.ToAbsolute(path), lastModifiedDate);
             htmlScript.RenderControl(htmlWriter);
         }
     }
     return new RawHtmlString(sb.ToString());
 }
开发者ID:xunter,项目名称:PavelNazarov.Common,代码行数:26,代码来源:HtmlIncludesExtensions.cs

示例10: AddPrevalueRow

        /// <summary>
        /// Adds a new row to the Prevalue Editor, (with an optional description).
        /// </summary>
        /// <param name="writer">The HtmlTextWriter.</param>
        /// <param name="label">The label for the field.</param>
        /// <param name="description">The description for the field.</param>
        /// <param name="controls">The controls for the field.</param>
        public static void AddPrevalueRow(this HtmlTextWriter writer, string label, string description, params Control[] controls)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix");
            writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row'

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "label");
            writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'label'

            var lbl = new HtmlGenericControl("label") { InnerText = label };

            if (controls.Length > 0 && !string.IsNullOrEmpty(controls[0].ClientID))
            {
                lbl.Attributes.Add("for", controls[0].ClientID);
            }

            lbl.RenderControl(writer);

            writer.RenderEndTag(); // end 'label'

            writer.AddAttribute(HtmlTextWriterAttribute.Class, "field");
            writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'field'

            foreach (var control in controls)
            {
                control.RenderControl(writer);
            }

            writer.RenderEndTag(); // end 'field'

            if (!string.IsNullOrEmpty(description))
            {
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "description");
                writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'description'

                var desc = new Literal() { Text = description };
                desc.RenderControl(writer);

                writer.RenderEndTag(); // end 'description'
            }

            writer.RenderEndTag(); // end 'row'
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:49,代码来源:PrevalueEditorExtensions.cs

示例11: Render

        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl section = new HtmlGenericControl("div");
            section.Attributes["class"] = "archiveLinksContainerStyle";
            this.Controls.Add(section);

            Table list = new Table();
            list.CssClass = "archiveLinksTableStyle";
            section.Controls.Add(list);

            try
            {
                foreach (DateTime date in _monthList)
                {
                    TableRow row = new TableRow();
                    TableCell cell = new TableCell();
                    //cell.CssClass ="archiveLinksCellStyle";
                    list.Rows.Add(row);
                    row.Cells.Add(cell);

                    HyperLink monthLink = new HyperLink();
                    //monthLink.CssClass = "archiveLinksLinkStyle";
                    string monthKey = date.ToString("MMMM, yyyy");
                    monthLink.Text = monthKey +" (" + _monthTable[monthKey] +")";
                    monthLink.NavigateUrl = SiteUtilities.GetMonthViewUrl(_requestPage.SiteConfig, date);
                    cell.Controls.Add(monthLink);
                }
            }
            catch( Exception exc )
            {
                ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error,exc);
                section.Controls.Add(new LiteralControl("There was an error generating archive list<br />"));
            }

            section.RenderControl( writer );
        }
开发者ID:AArnott,项目名称:dasblog,代码行数:36,代码来源:ArchiveMonthsList.cs

示例12: RenderHtmlBody

        /// <summary>
        /// Writes the HTML Body element.
        /// </summary>
        protected virtual void RenderHtmlBody()
        {
            // Create the body tag and set it up so that Render calls
            // will have it available
            _body = new HtmlGenericControl("body");

            if (_showHeader)
                RenderPageHeader();

            RenderContents();

            if (_showFooter)
                RenderPageFooter();

            Page.Controls.Add(_body);
            _body.RenderControl(_writer);
            _writer.WriteLine();
        }
开发者ID:tresat,项目名称:LogEm,代码行数:21,代码来源:LogEmPageBase.cs

示例13: RenderMonths

        private string RenderMonths(SortedDictionary<DateTime, int> Months)
        {
            if (Months.Keys.Count == 0)
                return string.Empty;

            HtmlGenericControl ul = new HtmlGenericControl("ul");
            ul.Attributes.Add("id", "blogMonthList");
            HtmlGenericControl year = null;
            HtmlGenericControl list = null;
            int current = 0;

            foreach (DateTime date in Months.Keys)
            {
                if (current == 0)
                    current = date.Year;

                if (date.Year > current || ul.Controls.Count == 0)
                {
                    list = new HtmlGenericControl("ul");
                    list.ID = "year" + date.Year.ToString();

                    year = new HtmlGenericControl("li");
                    year.Attributes.Add("class", "year");
                    year.InnerHtml = date.Year.ToString();
                    year.Controls.Add(list);

                    ul.Controls.AddAt(0, year);
                }

                HtmlGenericControl li = new HtmlGenericControl("li");

                HtmlAnchor anc = new HtmlAnchor();
                string url = SEOHelper.GetBlogUrlByMonth(date);
                anc.HRef = url;
                anc.InnerHtml = new DateTime(date.Year, date.Month, 1).ToString("MMMM") + " (" + Months[date] + ")";

                li.Controls.Add(anc);
                list.Controls.AddAt(0, li);
                current = date.Year;
            }

            StringWriter sw = new StringWriter();
            ul.RenderControl(new HtmlTextWriter(sw));
            return sw.ToString();
        }
开发者ID:robbytarigan,项目名称:ToyHouse,代码行数:45,代码来源:BlogMonths.ascx.cs

示例14: Render

        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl iFrame = new HtmlGenericControl("iframe");
            iFrame.Attributes.Add("name", this.JsonId + "_iframe");
            HtmlGenericControl hidden = new HtmlGenericControl("input");
            hidden.Attributes.Add("type", "hidden");
            hidden.Attributes.Add("name", "JsonId");
            hidden.Attributes.Add("value", this.JsonId);

            //HtmlGenericControl fileName = new HtmlGenericControl("input");
            //fileName.Attributes.Add("type", "hidden");
            //fileName.Attributes.Add("name", "filename");
            //fileName.Attributes.Add("value", this.JsonId + "_value");

            HtmlGenericControl form = new HtmlGenericControl("form");
            form.Attributes.Add("enctype", "multipart/form-data");
            form.Attributes.Add("action", HttpContextHelper.AbsolutePageUrl);
            form.Attributes.Add("target", this.JsonId + "_iframe");
            form.Attributes.Add("method", "post");
            form.Attributes.Add("jsonid", this.JsonId);

            HtmlGenericControl file = new HtmlGenericControl("input");
            file.Attributes.Add("type", "file");
            file.Attributes.Add("name", "file");
            file.Attributes.Add("onchange", "JSUI.uploadMgr.setFileName('" + this.JsonId + "');");
            form.Controls.Add(hidden);
            //form.Controls.Add(fileName);
            form.Controls.Add(file);
            iFrame.RenderControl(writer);

            HtmlGenericControl msg = ControlHelper.NewDiv(this.JsonId + "_message");
            msg.Style.Add("display", "none");
            if (!string.IsNullOrEmpty(this.MessageCssClass))
                msg.Attributes.Add("class", this.MessageCssClass);

            form.Controls.Add(msg);
            form.RenderControl(writer);

            if (this.RenderScripts)
                this.RenderConglomerateScript(writer);
        }
开发者ID:BryanApellanes,项目名称:Naizari,代码行数:41,代码来源:DataFileUpload.cs

示例15: RenderComments

        /// <summary>
        /// Renders the comments.
        /// </summary>
        /// <returns>The HTML string.</returns>
        private static string RenderComments()
        {
            if (Comments.Count == 0)
            {
                return string.Format("<p>{0}</p>", labels.none);
            }

            using (var ul = new HtmlGenericControl("ul"))
            {
                ul.Attributes.Add("class", "recentComments");
                ul.ID = "recentComments";

                foreach (var comment in Comments.Where(comment => comment.IsApproved))
                {
                    var li = new HtmlGenericControl("li");

                    // The post title
                    var title = new HtmlAnchor { HRef = comment.Parent.RelativeOrAbsoluteLink, InnerText = comment.Parent.Title };
                    title.Attributes.Add("class", "postTitle");
                    li.Controls.Add(title);

                    // The comment count on the post
                    var count =
                        new LiteralControl(string.Format(" ({0})<br />", ((Post)comment.Parent).ApprovedComments.Count));
                    li.Controls.Add(count);

                    // The author
                    if (comment.Website != null)
                    {
                        var author = new HtmlAnchor { HRef = comment.Website.ToString(), InnerHtml = comment.Author };
                        author.Attributes.Add("rel", "nofollow");
                        li.Controls.Add(author);

                        var wrote = new LiteralControl(string.Format(" {0}: ", labels.wrote));
                        li.Controls.Add(wrote);
                    }
                    else
                    {
                        var author = new LiteralControl(string.Format("{0} {1}: ", comment.Author, labels.wrote));
                        li.Controls.Add(author);
                    }

                    // The comment body
                    var commentBody = Regex.Replace(comment.Content, @"\[(.*?)\]", string.Empty);
                    var bodyLength = Math.Min(commentBody.Length, 50);

                    commentBody = commentBody.Substring(0, bodyLength);
                    if (commentBody.Length > 0)
                    {
                        if (commentBody[commentBody.Length - 1] == '&')
                        {
                            commentBody = commentBody.Substring(0, commentBody.Length - 1);
                        }
                    }

                    commentBody += comment.Content.Length <= 50 ? " " : "� ";
                    var body = new LiteralControl(commentBody);
                    li.Controls.Add(body);

                    // The comment link
                    var link = new HtmlAnchor
                        {
                            HRef = string.Format("{0}#id_{1}", comment.Parent.RelativeOrAbsoluteLink, comment.Id), InnerHtml = string.Format("[{0}]", labels.more)
                        };
                    link.Attributes.Add("class", "moreLink");
                    li.Controls.Add(link);

                    ul.Controls.Add(li);
                }

                using (var sw = new StringWriter())
                {
                    ul.RenderControl(new HtmlTextWriter(sw));
                    return sw.ToString();
                }
            }
        }
开发者ID:royosherove,项目名称:tddnetcoursedemos,代码行数:81,代码来源:RecentComments.cs


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