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


C# HtmlTextWriter类代码示例

本文整理汇总了C#中HtmlTextWriter的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter类的具体用法?C# HtmlTextWriter怎么用?C# HtmlTextWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: RenderEmailFolders

    public void RenderEmailFolders()
    {
        var html = new StringBuilder();

        // Get the data
        var service = new MessagesService();
        var folders = service.GetEmailFolders();


        // Group the data
        var standardFolderTypes = new List<int> { 1, 2, 3, 4 };
        var standardFolders = folders.Where(c => standardFolderTypes.Contains(c.MailFolderTypeID));

        var personalFolderTypes = new List<int> { 0 };
        var personalFolders = folders.Where(c => personalFolderTypes.Contains(c.MailFolderTypeID));


        // Render the standard folders first
        html.AppendFormat("<ul class='nav nav-pills nav-stacked'>");
        foreach(var folder in standardFolders)
        {
            // Determine if we have any uinread messages in this folder
            var hasUnreadMessages = folder.UnreadCount > 0;
            var cssClass = (hasUnreadMessages) ? "active" : string.Empty;
            var unreadCountDisplay = (hasUnreadMessages) ? string.Format("&nbsp;({0})", folder.UnreadCount) : string.Empty;
            
            // Render the list item
            html.AppendFormat("<li class='{0}'><a href='Messages.aspx?f={3}'>{1}{2}</a></li>",
                cssClass,
                folder.Name,
                unreadCountDisplay,
                folder.MailFolderID);
        }
        html.AppendFormat("</ul>");


        // Render the personal folders next
        html.AppendFormat("<ul class='nav nav-pills nav-stacked'>");
        foreach(var folder in personalFolders)
        {
            // Determine if we have any uinread messages in this folder
            var hasUnreadMessages = folder.UnreadCount > 0;
            var cssClass = (hasUnreadMessages) ? "active" : string.Empty;
            var unreadCountDisplay = (hasUnreadMessages) ? string.Format("&nbsp;({0})", folder.UnreadCount) : string.Empty;
            
            // Render the list item
            html.AppendFormat("<li class='{0}'><a href='Messages.aspx?f={3}'>{1}{2}</a></li>",
                cssClass,
                folder.Name,
                unreadCountDisplay,
                folder.MailFolderID);
        }

        html.AppendFormat("</ul>");


        // Write the HTML to the screen
        var writer = new HtmlTextWriter(Response.Output);
        writer.Write(html.ToString());
    }
开发者ID:BakerWebDev,项目名称:strongbrook.me,代码行数:60,代码来源:Messages.aspx.cs

示例2: RenderRepeater

		// What is baseControl for ?
		public void RenderRepeater (HtmlTextWriter w, IRepeatInfoUser user, Style controlStyle, WebControl baseControl)
		{
			PrintValues (user);
			RepeatLayout layout = RepeatLayout;
			bool listLayout = layout == RepeatLayout.OrderedList || layout == RepeatLayout.UnorderedList;

			if (listLayout) {
				if (user != null) {
					if ((user.HasHeader || user.HasFooter || user.HasSeparators))
						throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support headers, footers or separators.");
				}

				if (OuterTableImplied)
					throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support implied outer tables.");

				int cols = RepeatColumns;
				if (cols > 1)
					throw new InvalidOperationException ("The UnorderedList and OrderedList layouts do not support multi-column layouts.");
			}
			if (RepeatDirection == RepeatDirection.Vertical) {
				if (listLayout)
					RenderList (w, user, controlStyle, baseControl);
				else
					RenderVert (w, user, controlStyle, baseControl);
			} else {
				if (listLayout)
						throw new InvalidOperationException ("The UnorderedList and OrderedList layouts only support vertical layout.");
				RenderHoriz (w, user, controlStyle, baseControl);
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:31,代码来源:RepeatInfo.cs

示例3: AddAttributesToRender

		protected override void AddAttributesToRender (HtmlTextWriter writer)
		{
			base.AddAttributesToRender (writer);
			if (writer != null) {
				object o = ViewState ["AbbreviatedText"];
				if (o != null)
					writer.AddAttribute (HtmlTextWriterAttribute.Abbr, (string) o);

				switch (Scope) {
				case TableHeaderScope.Column:
					writer.AddAttribute (HtmlTextWriterAttribute.Scope, "column", false);
					break;
				case TableHeaderScope.Row:
					writer.AddAttribute (HtmlTextWriterAttribute.Scope, "row", false);
					break;
				}

				string[] cats = CategoryText;
				if (cats.Length == 1) {
					writer.AddAttribute (HtmlTextWriterAttribute.Axis, cats [0]);
				} else if (cats.Length > 1) {
					StringBuilder sb = new StringBuilder ();
					for (int i=0; i < cats.Length - 1; i++) {
						sb.Append (cats [i]);
						sb.Append (",");
					}
					sb.Append (cats [cats.Length - 1]);
					writer.AddAttribute (HtmlTextWriterAttribute.Axis, sb.ToString ());
				}
			}
		}
开发者ID:Profit0004,项目名称:mono,代码行数:31,代码来源:TableHeaderCell.cs

示例4: Render

		protected internal override void Render (HtmlTextWriter w)
		{
			/* make sure all the child controls have been created */
			EnsureChildControls ();
			/* and then... */
			base.Render (w);
		}
开发者ID:Profit0004,项目名称:mono,代码行数:7,代码来源:CompositeControl.cs

示例5: RenderChildren

		protected internal override void RenderChildren (HtmlTextWriter writer)
		{
			base.RenderChildren (writer);
			if (title == null) {
				writer.RenderBeginTag (HtmlTextWriterTag.Title);
				if (!String.IsNullOrEmpty (titleText))
					writer.Write (titleText);
				writer.RenderEndTag ();
			}
#if NET_4_0
			if (descriptionMeta == null && descriptionText != null) {
				writer.AddAttribute ("name", "description");
				writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (descriptionText));
				writer.RenderBeginTag (HtmlTextWriterTag.Meta);
				writer.RenderEndTag ();
			}

			if (keywordsMeta == null && keywordsText != null) {
				writer.AddAttribute ("name", "keywords");
				writer.AddAttribute ("content", HttpUtility.HtmlAttributeEncode (keywordsText));
				writer.RenderBeginTag (HtmlTextWriterTag.Meta);
				writer.RenderEndTag ();
			}
#endif
			if (styleSheet != null)
				styleSheet.Render (writer);
		}
开发者ID:nobled,项目名称:mono,代码行数:27,代码来源:HtmlHead.cs

示例6: Button1_Click

    protected void Button1_Click(object sender, EventArgs e)
    {


        BoletoBancario  itau = PreparaBoleto();
        MailMessage mail = PreparaMail();

        if (RadioButton1.Checked)
        {
            mail.Subject += " - On-Line";
            Panel1.Controls.Add(itau);

            System.IO.StringWriter sw = new System.IO.StringWriter();
            HtmlTextWriter htmlTW = new HtmlTextWriter(sw);
            Panel1.RenderControl(htmlTW);
            string html = sw.ToString();
            //
            mail.Body = html;
        }
        else
        {
            mail.Subject += " - Off-Line";
            mail.AlternateViews.Add(itau.HtmlBoletoParaEnvioEmail());
        }

        MandaEmail(mail);
        Label1.Text = "Boleto simples enviado para o email: " + TextBox1.Text;
    }
开发者ID:richardsonvix,项目名称:boletonet,代码行数:28,代码来源:EnvioEmail.aspx.cs

示例7: ExportDataSetToExcel

    public static void ExportDataSetToExcel(DataSet ds, string filename)
    {
        try
        {
            HttpResponse response = HttpContext.Current.Response;

            // first let's clean up the response.object
            response.Clear();
            response.Charset = "";

            // set the response mime type for excel
            response.ContentType = "application/vnd.ms-excel";
            response.AddHeader("Content-Disposition", "attachment;filename=\"" + filename + "\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    // instantiate a datagrid
                    DataGrid dg = new DataGrid();
                    dg.Font.Size = 9;
                    dg.DataSource = ds.Tables[0];
                    dg.DataBind();
                    dg.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
        catch (Exception)
        {
            throw;
        }
    }
开发者ID:frdharish,项目名称:WhitfieldAPPs,代码行数:35,代码来源:master_materials.aspx.cs

示例8: btnPDF_Click

 protected void btnPDF_Click(object sender, ImageClickEventArgs e)
 {
     Response.ContentType = "application/pdf";
     Response.AddHeader("content-disposition", "attachment;filename=UserDetails.pdf");
     Response.Cache.SetCacheability(HttpCacheability.NoCache);
     StringWriter sw = new StringWriter();
     HtmlTextWriter hw = new HtmlTextWriter(sw);
     gvdetails.AllowPaging = false;
     gvdetails.DataBind();
     gvdetails.RenderControl(hw);
     gvdetails.HeaderRow.Style.Add("width", "15%");
     gvdetails.HeaderRow.Style.Add("font-size", "10px");
     gvdetails.Style.Add("text-decoration", "none");
     gvdetails.Style.Add("font-family", "Arial, Helvetica, sans-serif;");
     gvdetails.Style.Add("font-size", "8px");
     StringReader sr = new StringReader(sw.ToString());
     Document pdfDoc = new Document(PageSize.A2, 7f, 7f, 7f, 0f);
     HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
     PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
     pdfDoc.Open();
     htmlparser.Parse(sr);
     pdfDoc.Close();
     Response.Write(pdfDoc);
     Response.End();
 }
开发者ID:dineshkummarc,项目名称:DataExportusingDotNet,代码行数:25,代码来源:Default.aspx.cs

示例9: GetControlsHTML

 public string GetControlsHTML(Control c)
 {
     System.IO.StringWriter sw = new System.IO.StringWriter();
     HtmlTextWriter hw = new HtmlTextWriter(sw);
     c.RenderControl(hw);
     return sw.ToString();
 }
开发者ID:fping1245,项目名称:test20121224,代码行数:7,代码来源:clssche.aspx.cs

示例10: btnExport_Click

    protected void btnExport_Click(object sender, EventArgs e)
    {
        using (StringWriter sw = new StringWriter())
        {
            using (HtmlTextWriter hw = new HtmlTextWriter(sw))
            {
                //To Export all pages
                grid_monthly_attendanceDetailed.AllowPaging = false;
                //this.BindGrid();

                grid_monthly_attendanceDetailed.RenderBeginTag(hw);
                grid_monthly_attendanceDetailed.HeaderRow.RenderControl(hw);
                foreach (GridViewRow row in grid_monthly_attendanceDetailed.Rows)
                {
                    row.RenderControl(hw);
                }
                grid_monthly_attendanceDetailed.FooterRow.RenderControl(hw);
                grid_monthly_attendanceDetailed.RenderEndTag(hw);
                StringReader sr = new StringReader(sw.ToString());
                Document pdfDoc = new Document(PageSize.A2, 10f, 10f, 10f, 0f);
                HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
                PdfWriter.GetInstance(pdfDoc, Response.OutputStream);
                pdfDoc.Open();
                htmlparser.Parse(sr);
                pdfDoc.Close();

                Response.ContentType = "application/pdf";
                Response.AddHeader("content-disposition", "attachment;filename=Report.pdf");
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.Write(pdfDoc);
                Response.End();
            }
        }
    }
开发者ID:hmandal,项目名称:BiometricsAttendanceSystem,代码行数:34,代码来源:MonthlyAttendanceEmployeeWise.aspx.cs

示例11: ShowThisMessage

    protected void ShowThisMessage()
    {
        HtmlTextWriter writer = new HtmlTextWriter(Response.Output);
        StringBuilder s = new StringBuilder();

        s.AppendLine(string.Format(@"
             <div class=""panelarea panel"" id=""reciept"" style=""position: absolute; width: 100%;"">
                 <h1 class=""heading"">Thank You</h1>
                 <table class=""grid"" id=""grid2"">
                     <tbody>
                         <tr class=""gridrow first last"">
                             <td class=""col0 gridcell first"">
                                 <div class=""notes panel"" style=""color:black;"">
                                    <p>Congratulations on taking your first step towards receiving your one-on-one custom Game Plan Report. This Game Plan Report will outline your financial options for moving you closer to achieving your retirement goals and dreams.</p>
                                    
                                    <p>A Game Plan Counselor will attempt to call you at your requested appointment time, or within the next 2 business days. Your Game Plan Counselor will spend a few minutes asking questions to generate your custom Game Plan Report.</p>

                                    <p>Check your email for confirmation of your Game Plan request. 

                                    <p>We look forward to showing you options that will help create, manage, protect and grow your wealth.

                                    <p>
                                        Successfully,
                                        <br />
                                        Strongbrook Team
                                    <p>
                                 </div>
                             </td>
                             <td class=""col1 gridcell last"">
                                 <div class=""reminder panel"" id=""reminder""></div>
                             </td>
                         </tr>
                     </tbody>
                 </table>
             </div>"
        ));

        writer.Write(s.ToString());
    }
开发者ID:BakerWebDev,项目名称:strongbrook.net,代码行数:30,代码来源:GamePlanSubmissionThankYou.aspx.cs

示例12: ExportExcel

    public void ExportExcel(DataTable dt, string title, string from_time, string to_time, string User)
    {
        GridView GridView8 = new GridView();
        GridView8.AllowPaging = false;

        DataTable dt_Header = new DataTable();
        dt_Header.Columns.Add("Thong_Tin", typeof(string));

        dt_Header.Rows.Add("");
        dt_Header.Rows.Add("" + title);
        dt_Header.Rows.Add("");
        dt_Header.Rows.Add("User: " + User);
        dt_Header.Rows.Add("");
        dt_Header.Rows.Add("Tu ngay: " + from_time);
        dt_Header.Rows.Add("Den ngay: " + to_time);
        dt_Header.Rows.Add("");

        GridView GridView7 = new GridView();
        GridView7.AllowPaging = false;
        GridView7.DataSource = dt_Header;
        GridView7.BorderStyle = BorderStyle.None;
        GridView7.DataBind();

        //Add row if no data found
        //if (dt.Rows.Count <= 0)
        //{
        //    int num_col = dt.Columns.Count;
        //    dt.Rows.Add();
        //}
        GridView8.DataSource = dt;
        GridView8.DataBind();
        Response.Clear();
        Response.Buffer = true;
        Response.AddHeader("content-disposition", "attachment;filename=" + User + "_Report.xls");
        Response.Charset = "";
        Response.ContentType = "application/vnd.ms-excel";
        StringWriter sw = new StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(sw);

        for (int i = 0; i < GridView7.Rows.Count; i++)
        {
            //Apply text style to each Row
            GridView7.Rows[i].Attributes.Add("class", "textmode");
        }
        GridView7.RenderControl(hw);

        for (int i = 0; i < GridView8.Rows.Count; i++)
        {
            //Apply text style to each Row
            GridView8.Rows[i].Attributes.Add("class", "textmode");
        }

        GridView8.RenderControl(hw);
        //style to format numbers to string
        string style = @"<style> .textmode { mso-number-format:\@; } </style>";
        Response.Write(style);
        Response.Output.Write(sw.ToString());
        Response.Flush();
        Response.End();
    }
开发者ID:phongferrari,项目名称:source-code-nama,代码行数:60,代码来源:Report_Theo_Doi_STK_TSDB.aspx.cs

示例13: bt_Export_Click

    protected void bt_Export_Click(object sender, EventArgs e)
    {
        BindGrid(true, false);

        string filename = HttpUtility.UrlEncode(Encoding.UTF8.GetBytes(lb_ReportTitle.Text.Trim() == "" ? "Export" : lb_ReportTitle.Text.Trim()));
        Response.Charset = "UTF-8";
        Response.ContentEncoding = System.Text.Encoding.UTF8;
        Response.ContentType = "application/ms-excel";
        Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename + ".xls");
        Page.EnableViewState = false;

        StringWriter tw = new System.IO.StringWriter();
        HtmlTextWriter hw = new HtmlTextWriter(tw);
        GridView1.RenderControl(hw);

        try
        {
            string tmp0 = "<tr align=\"left\" valign=\"middle\" OnMouseOver=\"this.style.cursor='hand';this.originalcolor=this.style.backgroundColor;this.style.backgroundColor='#FFCC66';\" OnMouseOut=\"this.style.backgroundColor=this.originalcolor;\" style=\"height:18px;\">";
            string tmp1 = "<tr align=\"left\" valign=\"middle\" OnMouseOver=\"this.style.cursor='hand';this.originalcolor=this.style.backgroundColor;this.style.backgroundColor='#FFCC66';\" OnMouseOut=\"this.style.backgroundColor=this.originalcolor;\" style=\"background-color:White;height:18px;\">";
            StringBuilder outhtml = new StringBuilder(tw.ToString());
            outhtml = outhtml.Replace(tmp0, "<tr>");
            outhtml = outhtml.Replace(tmp1, "<tr>");
            outhtml = outhtml.Replace("&nbsp;", "");

            Response.Write(outhtml.ToString());
        }
        catch
        {
            Response.Write(tw.ToString());
        }
        Response.End();

        BindGrid(false, false);
    }
开发者ID:fuhongliang,项目名称:GraduateProject,代码行数:34,代码来源:ReportViewer.aspx.cs

示例14: btnExportTOWord_Click

    protected void btnExportTOWord_Click(object sender, EventArgs e)
    {
        try
        {
            pnlTicket.Visible = true;
            // BindLabelData();
            Response.Clear();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment;filename=Ticket.doc");
            Response.Charset = "";
            Response.ContentType = "application/vnd.ms-word";
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            pnlTicket.RenderControl(hw);
            Response.Output.Write(sw.ToString());
            Response.Flush();
            Response.End();
        }
        catch (System.Threading.ThreadAbortException lException)
        {

            // do nothing

        }
    }
开发者ID:srisai339,项目名称:LoveJourney_Working,代码行数:25,代码来源:Bookings.aspx.cs

示例15: btnExport2Excel_Click

    protected void btnExport2Excel_Click(object sender, EventArgs e)
    {
        Response.ClearContent();
        Response.AppendHeader("content-disposition", "attachment; filename=Evaluation Report between " + txtStartDate.Text + " and " + txtEndDate.Text + ".xls");
        Response.ContentType = "application/excel";

        StringWriter stringWrite = new StringWriter();
        HtmlTextWriter htmlTextWrite = new HtmlTextWriter(stringWrite);

        GridView2.HeaderRow.Style.Add("background-color", "#FFFFFF");
        foreach (TableCell tableCell in GridView2.HeaderRow.Cells)
        {
            tableCell.Style["background-color"] = "#5D7B9D";
        }

        foreach (GridViewRow gridViewRow in GridView2.Rows)
        {
            gridViewRow.BackColor = System.Drawing.Color.White;
            foreach (TableCell gridViewRowTableCell in gridViewRow.Cells)
            {
                gridViewRowTableCell.Style["background-color"] = "#F7F6F3";
            }
        }

        GridView2.RenderControl(htmlTextWrite);
        Response.Write(stringWrite.ToString());
        Response.End();
    }
开发者ID:jLeta,项目名称:HN_HR_1.0,代码行数:28,代码来源:Evaluation.aspx.cs


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