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


C# HtmlTextWriter.ToString方法代码示例

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


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

示例1: ExportExcel

        public ActionResult ExportExcel()
        {
            string xmlData = HttpContext.Server.MapPath("~/App_Data/GridColumn.xml");//Path of the xml script
            DataSet ds = new DataSet();//Using dataset to read xml file
            ds.ReadXml(xmlData);

            DataTable dtRecords = ds.Tables[0];// Data Table
            int recordsCount = dtRecords.Rows.Count;

            var grid = new GridView();
            grid.DataSource = dtRecords;
            grid.DataBind();

            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=MyExcelFile.xls");
            Response.ContentType = "application/ms-excel";

            Response.Charset = "";
            StringWriter sw = new StringWriter();
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            DownloadFileActionResult download = new DownloadFileActionResult(grid, "Cars.xls");
            download.ExecuteResult(this.ControllerContext);
            grid.RenderControl(htw);

            Response.Output.Write(htw.ToString());
            Response.Flush();
            Response.End();

            return new EmptyResult();
        }
开发者ID:Kesavan2013,项目名称:PDSolution,代码行数:32,代码来源:HomeController.cs

示例2: IgnoresChildren

		public void IgnoresChildren ()
		{
			Button b = new  Button ();
			b.Controls.Add (new LiteralControl ("hola"));
			Assert.AreEqual (1, b.Controls.Count, "controls");
			StringWriter sw = new StringWriter ();
			HtmlTextWriter tw = new HtmlTextWriter (sw);
			b.RenderControl (tw);
			string str = tw.ToString ();
			Assert.AreEqual (-1, str.IndexOf ("hola"), "hola");
		}
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:11,代码来源:ButtonTest.cs

示例3: GetControl

 /// <summary>
 /// Renders The Given Control Into The String Output
 /// </summary>
 /// <param name="control">The WebControl To Be Converted</param>
 /// <returns>The Rendered Result Of The Given Control</returns>
 /// 
 private static string GetControl(WebControl control)
 {
     StringWriter stringWriter = new StringWriter();
     HtmlTextWriter textWriter = new HtmlTextWriter(stringWriter);
     control.RenderControl(textWriter);
     textWriter.Flush();
     return textWriter.ToString();
 }
开发者ID:asr340,项目名称:owasp-code-central,代码行数:14,代码来源:Convertors.cs


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