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


C# Page.RenderControl方法代码示例

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


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

示例1: PrintWebControl

 public static void PrintWebControl(Control ctrl, string Script)
 {
     StringWriter stringWrite = new StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     if (ctrl is WebControl)
     {
         Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
     }
     Page pg = new Page();
     pg.EnableEventValidation = false;
     if (Script != string.Empty)
     {
         pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
     }
     HtmlForm frm = new HtmlForm();
     pg.Controls.Add(frm);
     frm.Attributes.Add("runat", "server");
     frm.Controls.Add(ctrl);
     pg.DesignerInitialize();
     pg.RenderControl(htmlWrite);
     string strHTML = stringWrite.ToString();
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Write(strHTML);
     HttpContext.Current.Response.Write("<script>window.print();</script>");
     HttpContext.Current.Response.End();
 }
开发者ID:manivts,项目名称:impexcubeapp,代码行数:26,代码来源:PrintHelper.cs

示例2: PrintWebControl

        public void PrintWebControl(Control ControlToPrint)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ControlToPrint is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage);
                ((WebControl)ControlToPrint).Width = w;

            }

            Page pg = new Page();

            pg.EnableEventValidation = false;
            HtmlForm frm = new HtmlForm();
            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ControlToPrint);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);

            string strHTML = stringWrite.ToString();
            string wstawka = Server.MapPath("~").ToString();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(htmlToImage(strHTML, zmianaAdresu(wstawka)));

            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();

            Response.Redirect("~/ListaImprez.aspx");
        }
开发者ID:donor,项目名称:Projects,代码行数:32,代码来源:Wplaty.aspx.cs

示例3: PrintWebControl

        public static void PrintWebControl(Control ctrl, string Script)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ctrl is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
            }
            Page pg = new Page();
            pg.EnableEventValidation = false;
            pg.StyleSheetTheme = "../CSS/order.css";
            if (Script != string.Empty)
            {
                pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
            }

            HtmlLink link = new HtmlLink();
            link.Href = "../CSS/order.css";
            HtmlForm frm = new HtmlForm();
            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ctrl);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);
            string strHTML = stringWrite.ToString();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write("<head runat='server'> <title>Printer - Bản in tại Support.evnit.evn.com.vn</title> <link type='text/css' rel='stylesheet' href='../CSS/order.css'><link type='text/css' rel='stylesheet' href='../CSS/style.css'></head>");
            HttpContext.Current.Response.Write(strHTML);
            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();
        }
开发者ID:trungjc,项目名称:quanlyhocsinh,代码行数:31,代码来源:PrintHelper.cs

示例4: GetFile

        public void GetFile(Page page)
        {
            Button1.Visible = false;
            HtmlDocument doc = new HtmlDocument();
            var tw = new StringWriter();
            var hw = new HtmlTextWriter(tw);
            page.RenderControl(hw);
            doc.LoadHtml(tw.ToString());

            string path = Server.MapPath("ExportTemplate.txt");
            string strtemplate = File.ReadAllText(path, Encoding.Default);

            string result = strtemplate.Replace("@", doc.DocumentNode.SelectSingleNode("//div[@class='maincontant']").InnerHtml);

            var str = "Export_" + DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".doc";
            HttpContext.Current.Response.Charset = "GB2312";
            HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("gb2312"); //注意编码
            HttpContext.Current.Response.AppendHeader("Content-Disposition",
                "attachment;filename=" + HttpUtility.UrlEncode(str, Encoding.UTF8));
            HttpContext.Current.Response.ContentType = "application/application/ms-word";

            HttpContext.Current.Response.Write(result);
            HttpContext.Current.Response.Flush();
            HttpContext.Current.Response.End();
        }
开发者ID:rdzzg,项目名称:SHMetroTestSystem,代码行数:25,代码来源:EvaluateItemResult.aspx.cs

示例5: imgBtnExportarExcelEjecucion_Click

        protected void imgBtnExportarExcelEjecucion_Click(object sender, ImageClickEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            Page page = new Page();
            HtmlForm form = new HtmlForm();

            gvIncidenciasBatch.AllowPaging = false;
            gvIncidenciasBatch.DataBind();
            gvIncidenciasBatch.EnableViewState = false;

            page.EnableEventValidation = false;

            page.DesignerInitialize();
            page.Controls.Add(form);
            form.Controls.Add(gvIncidenciasBatch);

            page.RenderControl(htw);

            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=ReporteIncidenciasBatch" + DateTime.Now.ToShortDateString() + ".xls");
            Response.Charset = "UTF-8";

            Response.ContentEncoding = System.Text.Encoding.Default;

            Response.Write(sb.ToString());
            Response.End();
        }
开发者ID:jlaua,项目名称:WebHomologacion,代码行数:31,代码来源:wfrmDescargarIncidenciasBatch.aspx.cs

示例6: Render

        /// <summary>
        /// 用指定的用户控件以及视图数据呈现结果,最后返回生成的HTML代码。
        /// 用户控件应从MyUserControlView&lt;T&gt;继承
        /// </summary>
        /// <param name="ucVirtualPath">用户控件的虚拟路径</param>
        /// <param name="model">视图数据</param>
        /// <returns>生成的HTML代码</returns>
        public static string Render(string ucVirtualPath, object model)
        {
            if (string.IsNullOrEmpty(ucVirtualPath))
                throw new ArgumentNullException("ucVirtualPath");

            Page page = new Page();
            Control ctl = page.LoadControl(ucVirtualPath);
            if (ctl == null)
                throw new InvalidOperationException(
                    string.Format("指定的用户控件 {0} 没有找到。", ucVirtualPath));

            if (model != null)
            {
                MyBaseUserControl myctl = ctl as MyBaseUserControl;
                if (myctl != null)
                    myctl.SetModel(model);
            }

            // 将用户控件放在Page容器中。
            page.Controls.Add(ctl);

            StringWriter output = new StringWriter();
            HtmlTextWriter write = new HtmlTextWriter(output, string.Empty);
            page.RenderControl(write);

            // 用下面的方法也可以的。
            //HttpContext.Current.Server.Execute(page, output, false);

            return output.ToString();
        }
开发者ID:webxiaohua,项目名称:SmartNetMVC,代码行数:37,代码来源:UcExecutor.cs

示例7: imgBtnExportarExcelArchivos_Click

        protected void imgBtnExportarExcelArchivos_Click(object sender, ImageClickEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            Page page = new Page();
            HtmlForm form = new HtmlForm();

            gvJobCancelacioneXTicket.AllowPaging = false;
            gvJobCancelacioneXTicket.DataBind();
            gvJobCancelacioneXTicket.EnableViewState = false;

            page.EnableEventValidation = false;

            page.DesignerInitialize();
            page.Controls.Add(form);
            form.Controls.Add(gvJobCancelacioneXTicket);

            page.RenderControl(htw);

            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=ArchivosDeProcedimiento.xls");
            Response.Charset = "UTF-8";

            //Response.Cache.SetCacheability(HttpCacheability.NoCache);
            Response.ContentEncoding = System.Text.Encoding.Default;

            Response.Write(sb.ToString());
            Response.End();
        }
开发者ID:jlaua,项目名称:WebHomologacion,代码行数:32,代码来源:wfrmTicketsEnEjecucionHostCertificacion.aspx.cs

示例8: PrintWebControl

        public static void PrintWebControl(Control ControlToPrint, Control MyStyle)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ControlToPrint is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage);
                ((WebControl)ControlToPrint).Width = w;
            }
            System.Web.UI.Page pg = new System.Web.UI.Page();
            pg.EnableEventValidation = false;
            HtmlForm frm = new HtmlForm();

            frm.Controls.Add(MyStyle);

            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ControlToPrint);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);
            string strHTML = stringWrite.ToString();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(strHTML);
            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();
        }
开发者ID:tsandtm,项目名称:BOEdu,代码行数:26,代码来源:Prints.cs

示例9: Export

        protected bool Export()
        {
            try
            {
                //Descargo el objeto tabla de la sesion con nombre "p_c" ó (Plan Operativo)
                HtmlTable objTable = (HtmlTable)Session["p_c"];

                //Instancio un objeto del tipo StringBuilder objsb
                StringBuilder objsb = new StringBuilder();

                //Instancio un objeto del tipo System.IO.StringWriter sw
                System.IO.StringWriter sw = new System.IO.StringWriter(objsb);

                //Instancio un objeto del tipo HtmlTextWriter htw
                HtmlTextWriter htw = new HtmlTextWriter(sw);

                //Instancio un objeto del tipo System.Web.UI.Page
                System.Web.UI.Page pagina = new System.Web.UI.Page();

                //Instancio un objeto del tipo HtmlForm
                var form = new HtmlForm();

                //Asigno valores a propiedades del objeto page instanciado
                pagina.EnableEventValidation = false;
                pagina.DesignerInitialize();

                //Agrego el formulario instaciado a la coleccionde paginas
                pagina.Controls.Add(form);

                //Agrego el objeto tabla a la coleccion de controles del formulario instanciado anteriormente
                form.Controls.Add(objTable);

                //Realizo el proceso de renderizacion para los elementos agregados a la pagina instanciada
                pagina.RenderControl(htw);

                //Limpio el canal de respuesta para esta peticion
                Response.Clear();

                //Habilito el buffer
                Response.Buffer = true;

                //Asigno el tipo de contenido
                Response.ContentType = "application/vnd.ms-excel";
                //Asigno el nombre del documento a exportar en el header del response
                Response.AddHeader("Content-Disposition", "attachment;filename=Plan_Operativo.xls");
                //Asigno el tipo de charset "UTF-8"
                Response.Charset = "UTF-8";
                //Establesco la configuracion por defecto para la codificacion
                Response.ContentEncoding = Encoding.Default;
                //Realizo el proceso de escritura para el objeto objsb
                Response.Write(objsb.ToString());
                //Finalizo la respuesta
                Response.End();
                return true;
            }
            catch (Exception) { return false; }
        }
开发者ID:MGGROUP,项目名称:BASICA,代码行数:57,代码来源:ReportMarcoLogico.aspx.cs

示例10: ProcessTemplate

 public override void ProcessTemplate(TextWriter writer, string templateName, IProcessResponse response,
                                      Domain domain)
 {
     if (!string.IsNullOrEmpty(templateName))
     {
         Page page = new Page();
         page.Controls.Add(LoadControl(templateName, page, response, domain));
         page.RenderControl(new HtmlTextWriter(writer));
     }
 }
开发者ID:timbooker,项目名称:dotObjects,代码行数:10,代码来源:WebFormsRenderer.cs

示例11: imgBtnExcel_Click

        protected void imgBtnExcel_Click(object sender, ImageClickEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            Page page = new Page();
            HtmlForm form = new HtmlForm();

            gdUsuario.EnableViewState = false;

            // Deshabilitar la validación de eventos, sólo asp.net 2
            page.EnableEventValidation = false;

            // Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
            page.DesignerInitialize();

            page.Controls.Add(form);
            form.Controls.Add(gdUsuario);

            page.RenderControl(htw);

            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=datosHotel.xls");
            Response.Charset = "UTF-8";
            Response.ContentEncoding = Encoding.Default;
            Response.Write(sb.ToString());
            Response.End();

            //Response.Clear();

            //Response.AddHeader("content-disposition", "attachment;filename=Catalogo_Productos.xls");

            //Response.Charset = "";

            //Response.ContentType = "application/vnd.xls";

            //StringWriter StringWriter = new System.IO.StringWriter();

            //HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);

            //gvDatosAdmin.AllowPaging = false;

            //Response.Write(StringWriter.ToString());

            //Response.End();
        }
开发者ID:kEpEx,项目名称:CreaturHotelListo,代码行数:49,代码来源:MostrarUsuarios.aspx.cs

示例12: PrintWebControl

        public void PrintWebControl(Control ControlToPrint)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ControlToPrint is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage);
                ((WebControl)ControlToPrint).Width = w;

            }

            Page pg = new Page();

            pg.EnableEventValidation = false;
            HtmlForm frm = new HtmlForm();
            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ControlToPrint);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);

            string strHTML = stringWrite.ToString();
            string wstawka = Server.MapPath("~").ToString();
            string path = String.Format("{0}\\Images\\Rezerwacje\\{1}.gif", Server.MapPath("~"), Session["ZamowienieId"]);

            //korzystanie z biblioteki websiteScreenshote

            WebsitesScreenshot.WebsitesScreenshot _Obj = new WebsitesScreenshot.WebsitesScreenshot();
            WebsitesScreenshot.WebsitesScreenshot.Result _Result = _Obj.CaptureHTML(htmlToImage(strHTML, zmianaAdresu(wstawka)));

            if (_Result == WebsitesScreenshot.WebsitesScreenshot.Result.Captured)
            {
                _Obj.ImageFormat = WebsitesScreenshot.WebsitesScreenshot.ImageFormats.GIF;
                _Obj.SaveImage(path);
            }
            _Obj.Dispose();

            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(strHTML);
            Session[Cart.Ident] = null;
            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();

            Response.Redirect("~/ListaImprez.aspx");
        }
开发者ID:donor,项目名称:Projects,代码行数:45,代码来源:CheckOut.aspx.cs

示例13: btnExportar_Command

 protected void btnExportar_Command(object sender, CommandEventArgs e)
 {
     if (e.CommandName == "Exportar")
     {
          if (GridView1.Rows.Count > 0 && GridView1.Visible == true )
         {
         //try
         //{
             lblMsj.Text = "";
             StringBuilder sb = new StringBuilder();
             StringWriter sw = new StringWriter(sb);
             HtmlTextWriter htw = new HtmlTextWriter(sw);
             System.Web.UI.Page page = new System.Web.UI.Page();
             HtmlForm form = new HtmlForm();
             GridView1.EnableViewState = false;
             // Deshabilitar la validación de eventos, sólo asp.net 2
             page.EnableEventValidation = false;
             // Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
             page.DesignerInitialize();
             page.Controls.Add(form);
             form.Controls.Add(GridView1);
             page.RenderControl(htw);
             Response.Clear();
             Response.Buffer = true;
             Response.ContentType = "application/vnd.ms-excel";
             Response.AddHeader("Content-Disposition", "attachment;filename=Evaluaciones.xls");
             Response.Charset = "UTF-8";
             Response.ContentEncoding = Encoding.Default;
             Response.Write(sb.ToString());
             Response.End();
         //}
         //catch (Exception ex)
         //{
         //    EventLogger ev = new EventLogger();
         //    ev.Save("EvaluacionesDetalle, export excel ", ex);
         //}
         }
          else
          {
              lblMsj.Text = "la tabla no contiene datos para exportar...";
          }
     }
 }
开发者ID:mborja,项目名称:mkpy_bccar,代码行数:43,代码来源:EvaluacionesDetalle.aspx.cs

示例14: Export

        protected bool Export()
        {
            try
            {
                string html = txtgantt_html.Value;

                html = html.Replace("!1!", ">");
                html = html.Replace("!2!", "<");
                html = html.Replace("!3!", "=");
                html = html.Replace("!4!", "#");
                html = html.Replace("!5!", "&");

                HtmlGenericControl objTable = new HtmlGenericControl("table");

                objTable.InnerHtml = html;

                StringBuilder objsb = new StringBuilder();
                System.IO.StringWriter sw = new System.IO.StringWriter(objsb);
                HtmlTextWriter htw = new HtmlTextWriter(sw);
                System.Web.UI.Page pagina = new System.Web.UI.Page();
                var form = new HtmlForm();
                pagina.EnableEventValidation = false;
                pagina.DesignerInitialize();
                pagina.Controls.Add(form);
                form.Controls.Add(objTable);
                pagina.RenderControl(htw);
                Response.Clear();
                Response.Buffer = true;
                Response.ContentType = "application/vnd.ms-excel";

                Response.AddHeader("Content-Disposition", "attachment;filename=Cronograma.xls");

                Response.Charset = "UTF-8";
                Response.ContentEncoding = Encoding.Default;
                Response.Write(objsb.ToString());
                Response.End();
                return true;
            }
            catch (Exception) { return false; }
        }
开发者ID:kaganyuksel,项目名称:esm,代码行数:40,代码来源:DiagramaGant.aspx.cs

示例15: ExportToExcel

 private void ExportToExcel(string nameReport, GridView wControl)
 {
     StringBuilder sb = new StringBuilder();
     StringWriter sw = new StringWriter(sb);
     HtmlTextWriter htw = new HtmlTextWriter(sw);
     Page page = new Page();
     ListarAsistencia form = new ListarAsistencia();
     wControl.EnableViewState = false;
     // Deshabilitar la validación de eventos, sólo asp.net 2
     page.EnableEventValidation = false;
     // Realiza las inicializaciones de la instancia de la clase Page que requieran los diseñadores RAD.
     page.DesignerInitialize();
     page.Controls.Add(form);
     form.Controls.Add(wControl);
     page.RenderControl(htw);
     Response.Clear();
     Response.Buffer = true;
     Response.ContentType = "application/vnd.ms-excel";
     Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
     Response.Charset = "UTF-8";
     Response.ContentEncoding = Encoding.Default;
     Response.Write(sb.ToString());
     Response.End();
 }
开发者ID:pabloguevara144,项目名称:RegistroAsistencia,代码行数:24,代码来源:ListarAsistencia.aspx.cs


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