protected override void Render(HtmlTextWriter writer) { this.ddlModello.DataBind(); this.ddlModello.Items.Add(new ListItem("None", "0")); base.Render(writer); }
protected void bt_Export_Click(object sender, EventArgs e) { gv_Summary.AllowPaging = false; BindGrid(); string filename = HttpUtility.UrlEncode("汇总单导出_" + DateTime.Now.ToString("yyyyMMddHHmmss")); 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); gv_Summary.RenderControl(hw); StringBuilder outhtml = new StringBuilder(tw.ToString()); outhtml = outhtml.Replace(" ", "").Replace("<br />", ""); Response.Write(outhtml.ToString()); Response.End(); gv_Summary.AllowPaging = true; BindGrid(); }
protected void btnExcel_Click(object sender, EventArgs e) { try { ChangeControlsToValue(gvDeposits); // gvDeposits.Columns[13].Visible = false; Response.ClearContent(); Response.AddHeader("content-disposition", "attachment; filename=AgentDeposits.xls"); Response.ContentType = "application/excel"; StringWriter sWriter = new StringWriter(); HtmlTextWriter hTextWriter = new HtmlTextWriter(sWriter); HtmlForm hForm = new HtmlForm(); gvDeposits.Parent.Controls.Add(hForm); hForm.Attributes["runat"] = "server"; hForm.Controls.Add(gvDeposits); hForm.RenderControl(hTextWriter); StringBuilder sBuilder = new StringBuilder(); sBuilder.Append("<html xmlns:v=\"urn:schemas-microsoft-com:vml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:x=\"urn:schemas-microsoft-com:office:excel\" xmlns=\"http://www.w3.org/TR/REC-html40\"> <head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=windows-1252\"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>ExportToExcel</x:Name><x:WorksheetOptions><x:Panes></x:Panes></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head> <body>"); sBuilder.Append(sWriter + "</body></html>"); Response.Write(sBuilder.ToString()); Response.End(); //gvDeposits.Columns[13].Visible = true; } catch (Exception ex) { //lblMsg.InnerHtml = ex.Message; throw ex; } }
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(" ({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(" ({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()); }
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 ()); } } }
/// <summary> /// /// </summary> /// <param name="sw"></param> public static void Export(StringWriter sw, GridView gv) { using (HtmlTextWriter htw = new HtmlTextWriter(sw)) { // Create a table to contain the grid Table table = new Table(); // include the gridline settings table.GridLines = gv.GridLines; // add the header row to the table if (gv.HeaderRow != null) { table.Rows.Add(gv.HeaderRow); } // add each of the data rows to the table foreach (GridViewRow row in gv.Rows) { table.Rows.Add(row); } // add the footer row to the table if (gv.FooterRow != null) { table.Rows.Add(gv.FooterRow); } // render the table into the htmlwriter table.RenderControl(htw); } }
// 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); } }
protected internal override void Render(HtmlTextWriter writer) { if (((WmlTextWriter)writer).AnalyzeMode) { return; } HtmlTextWriter w = new HtmlTextWriter(writer); Control.Render(w); }
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); }
// Needed so the CompositeControl renders correctly in the designer, even when it does not have // an associated ControlDesigner (i.e. it is a child control of another CompositeControl). protected internal override void Render(HtmlTextWriter writer) { if (DesignMode) { EnsureChildControls(); } base.Render(writer); }
protected internal override void Render (HtmlTextWriter w) { /* make sure all the child controls have been created */ EnsureChildControls (); /* and then... */ base.Render (w); }
protected void btnExcel_Click(object sender, EventArgs e) { //Add Exception handilng try catch change by vishal 21-05-2012 try { Response.Clear(); Response.AddHeader("content-disposition", "attachment;filename=AllSystemInfo.xls"); Response.Charset = ""; Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = "application/vnd.xls"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); dtgrid.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); } catch (Exception ex) { string myScript; myScript = "<script language=javascript>alert('Exception - '" + ex + "');</script>"; Page.RegisterClientScriptBlock("MyScript", myScript); return; } }
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; } }
public void RenderCompanyNewsDetail() { HtmlTextWriter writer = new HtmlTextWriter(Response.Output); StringBuilder s = new StringBuilder(); // Render the data if(NewsDetail.NewsID > 0 && NewsDetail.CompanySettings != NewsCompanySettings.AccessNotAvailable && NewsDetail.WebSettings == NewsWebSettings.AccessAvailable) { s.AppendLine(string.Format(@" <div class='newsdetail'> <div class='title'>{0}</div> <div class='date'>Published on {1:dddd, MMMM d, yyyy, h:mmtt}</div> <div class='content'>{2}</div> </div> ", NewsDetail.Description, NewsDetail.CreatedDate, NewsDetail.Content)); } else { Response.Redirect("Home.aspx"); } writer.Write(s.ToString()); }
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; }
protected override void RenderAttributes (HtmlTextWriter writer) { // make sure we don't render the password Attributes.Remove ("value"); base.RenderAttributes (writer); }
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 } }
/// <summary> /// 輸出為Excel /// </summary> /// <param name="webpage">傳入目前網頁Page變數</param> /// <param name="Dt">需要匯出的內容</param> /// <param name="FilePath">輸出的檔名</param> public void OutputExcel(Page webpage, DataTable Dt, string FilePath ) { GridView gvExport = new GridView(); gvExport.DataSource = Dt; gvExport.DataBind(); string UTF8FileName = HttpUtility.UrlEncode(FilePath, System.Text.Encoding.UTF8 ); webpage.Response.Clear(); webpage.Response.AddHeader("content-disposition", string.Format("attachment;filename={0}", UTF8FileName) ); webpage.Response.Cache.SetCacheability(HttpCacheability.NoCache); webpage.Response.ContentType = "application/vnd.ms-excel"; webpage.Response.Charset = "big5"; System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); gvExport.RenderControl(htmlWrite); webpage.Response.Write(stringWrite.ToString().Replace("<div>", "").Replace("</div>", "")); webpage.Response.End(); }
protected override void AddAttributesToRender (HtmlTextWriter w) { Page page = Page; if (page != null) page.VerifyRenderingInServerForm (this); base.AddAttributesToRender (w); bool enabled = IsEnabled; string onclick = OnClientClick; onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick); if (HasAttributes && Attributes ["onclick"] != null) { onclick = ClientScriptManager.EnsureEndsWithSemicolon (onclick + Attributes ["onclick"]); Attributes.Remove ("onclick"); } if (onclick.Length > 0) w.AddAttribute (HtmlTextWriterAttribute.Onclick, onclick); if (enabled && page != null) { PostBackOptions options = GetPostBackOptions (); string href = page.ClientScript.GetPostBackEventReference (options, true); w.AddAttribute (HtmlTextWriterAttribute.Href, href); } AddDisplayStyleAttribute (w); }
protected internal override void RenderContents(HtmlTextWriter writer) { // Copied from HyperLink.RenderContents() and modified slightly string imageUrl = ImageUrl; if (!String.IsNullOrEmpty(imageUrl)) { Image image = new Image(); // NOTE: The Url resolution happens right here, because the image is not parented // and will not be able to resolve when it tries to do so. image.ImageUrl = ResolveClientUrl(imageUrl); string toolTip = ToolTip; if (!String.IsNullOrEmpty(toolTip)) { image.ToolTip = toolTip; } string text = Text; if (!String.IsNullOrEmpty(text)) { image.AlternateText = text; } image.Page = Page; image.RenderControl(writer); } else { base.RenderContents(writer); } }
protected void DrawGridFooter(HtmlTextWriter output, Control ctl) { for (int i = 1; i < 4; i++) { output.Write("<tr>"); output.Write("<td height='22'>预选"); output.Write(i.ToString() + "</td>"); output.Write("<td bgcolor='#ffffff'> </td>"); output.Write("<td bgcolor='#ffffff'> </td>"); for (int k = 0; k < 0x1c; k++) { output.Write("<td bgcolor='#fdfcdf' onClick=Style(this,'#ff0000','#fdfcdf') style='color:#fdfcdf; cursor:pointer;' ><strong>"); output.Write(k.ToString() + "</td>"); } } output.Write("<tr align='center' valign='center' bgcolor='#e8f1f8' height='18px'>"); output.Write("<td rowspan='3' >期号</td>"); output.Write("<td rowspan='3' >开奖号码</td>"); output.Write("<td rowspan='2' >和值</td>"); for (int j = 0; j < 0x1c; j++) { output.Write("<td ><font color='blue'>"); output.Write(j.ToString() + "</font></td>"); } output.Write("<tr align='center' valign='middle' bgcolor='#e8f1f8' >"); output.Write("<td colspan='28' height='18px'>位置分布</td>"); output.Write("<tr align='center' valign='middle' bgcolor='#e8f1f8'>"); output.Write("<td colspan='29' height='18px'><strong><font color='red'>和值走势</font></strong></td>"); }
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(); }
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(); }
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(); } } }
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()); }
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: "******""); 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(); }
public string GetControlsHTML(Control c) { System.IO.StringWriter sw = new System.IO.StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); c.RenderControl(hw); return sw.ToString(); }
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(" ", ""); Response.Write(outhtml.ToString()); } catch { Response.Write(tw.ToString()); } Response.End(); BindGrid(false, false); }
private void DrawGridFooter(HtmlTextWriter output, Control ctl) { int num = this.RadioSelete(); output.Write("<td width = '100px' height='50px'>"); output.Write("出现次数</td>"); output.Write("<td width = '100px'>"); output.Write(" </td>"); for (int i = 2; i < this.GridView1.Columns.Count; i++) { int num3 = 0; for (int j = 0; j < this.GridView1.Rows.Count; j++) { if ((this.GridView1.Rows[j].Cells[i].Text == "0") || (this.GridView1.Rows[j].Cells[i].Text == "1")) { //num3 = num3; this.num[i - 2] = num3; this.sum[i - 2] = (num3 * 50) / num; } if ((((this.GridView1.Rows[j].Cells[i].Text == "2") || (this.GridView1.Rows[j].Cells[i].Text == "3")) || ((this.GridView1.Rows[j].Cells[i].Text == "4") || (this.GridView1.Rows[j].Cells[i].Text == "5"))) || ((this.GridView1.Rows[j].Cells[i].Text == "6") || (this.GridView1.Rows[j].Cells[i].Text == "7"))) { num3++; this.num[i - 2] = num3; this.sum[i - 2] = (num3 * 50) / num; } } output.Write("<td align='center' valign='bottom'>"); output.Write(this.num[i - 2].ToString() + "<br><img src='../image/01[1].gif' height='" + this.sum[i - 2].ToString() + "px' title = '" + this.num[i - 2].ToString() + "' width= '8px'></td>"); } }
protected override void Render(HtmlTextWriter writer) { this.txtChecked.RenderControl(writer); this.RenderInputTag(writer); }
public override void RenderImageLink(TreeNode node, HtmlTextWriter output) { int indent = node.Indent; StringBuilder builder = new StringBuilder(); while (indent > 0) { bool flag2; bool flag = node.NextSibling() != null; bool flag3 = node.Parent is TreeView; if (node.Parent is TreeNode) { flag2 = this.ParentHasSibling(node, node.Indent - indent); } else { flag2 = false; } if (node.Indent == indent) { if (node.HasControls()) { string text = "<a href=\"" + base.TreeView.Page.GetPostBackClientHyperlink(base.TreeView, node.UniqueID) + "\">"; string text2 = "</a>"; if (flag) { if (node.IsExpanded) { if (this.IsFirst()) { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "topexpandedsibling.gif' border='0'>" + text2); } else { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "middleexpandedsibling.gif' border='0'>" + text2); } } else if (this.IsFirst()) { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "topcollapsedsibling.gif' border='0'>" + text2); } else { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "middlecollapsedsibling.gif' border='0'>" + text2); } } else if (node.IsExpanded) { if (this.IsFirst()) { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "topexpandednosibling.gif' border='0'>" + text2); } else { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "middleexpandednosibling.gif' border='0'>" + text2); } } else if (this.IsFirst()) { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "topcollapsednosibling.gif' border='0'>" + text2); } else { builder.Insert(0, text + "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "middlecollapsednosibling.gif' border='0'>" + text2); } } else if (flag) { builder.Insert(0, "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "middlesiblingnochildren.gif' border='0'>"); } else { builder.Insert(0, "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "bottomnosiblingnochildren.gif' border='0'>"); } } else if (flag2) { builder.Insert(0, "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "vertbardots.gif' border='0'>"); } else { builder.Insert(0, "<img align='top' src='" + base.TreeView.WindowsLafImageBase + "clear.gif' border='0'>"); } indent--; } output.Write(builder.ToString()); }
public override void RenderTreeEnd(HtmlTextWriter output) { output.WriteEndTag("table"); }
public override void RenderNodeStart(TreeNode node, HtmlTextWriter output) { output.Write("<tr><td><nobr>"); }
public override void RenderNodeEnd(TreeNode node, HtmlTextWriter output) { output.Write("</nobr></td></tr>"); }
private void ExportToExcel(string nameReport, List <InformeProduccionM> lista, string Area, string Maquina, string fInicio) { HttpResponse response = Response; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); Page pageToRender = new Page(); HtmlForm form = new HtmlForm(); Label la = new Label(); string Titulo = "<div align='center'>Informe SobreImpresión<br/>"; if (Area != "") { Titulo += "Area : " + Area; } if (Maquina != "") { Titulo += " Maquina : " + Maquina; } if (fInicio != "") { Titulo += " Fecha : " + fInicio; } la.Text = Titulo + "</div><br />"; form.Controls.Add(la); #region ConversionListaGrilla int contado = 0; int TotalRotCantPlan = 0; int TotalRotCantPlanSobre = 0; int TotalRotCantProdSobre = 0; int TotalRotCantDifSobre = 0; double RotPorceCantDifSobre = 0; int TotalRotCantPlanBajo = 0; int TotalRotCantProdBajo = 0; int TotalRotCantDifBajo = 0; double RotPorceCantDifBajo = 0; int TotalPlaCantPlan = 0; int TotalPlaCantPlanSobre = 0; int TotalPlaCantProdSobre = 0; int TotalPlaCantDifSobre = 0; double PlaPorceCantDifSobre = 0; int TotalPlaCantPlanBajo = 0; int TotalPlaCantProdBajo = 0; int TotalPlaCantDifbajo = 0; double PlaPorceCantDifBajo = 0; foreach (string maquinasProd in lista.Select(o => o.Maquina).Distinct()) { GridView gv = new GridView(); gv.DataSource = lista.Where(o => o.Maquina == maquinasProd); gv.DataBind(); gv.HeaderStyle.BackColor = System.Drawing.Color.Blue; gv.HeaderStyle.ForeColor = System.Drawing.Color.White; gv.HeaderRow.Cells[0].Text = "Maquina"; gv.HeaderRow.Cells[1].Text = "OT"; gv.HeaderRow.Cells[2].Text = "NombreOT"; gv.HeaderRow.Cells[3].Text = "Pliego"; gv.HeaderRow.Cells[4].Text = "Cant. Planificado"; gv.HeaderRow.Cells[5].Text = "Cant. Producida"; gv.HeaderRow.Cells[6].Text = "Dif."; gv.HeaderRow.Cells[7].Text = "% "; if (Session["Usuario"].ToString().Trim() == "apaillaqueo" || Session["Usuario"].ToString().Trim() == "mandrade") { gv.HeaderRow.Cells[8].Visible = false; gv.HeaderRow.Cells[10].Visible = false; } else { gv.HeaderRow.Cells[8].Text = "Control Wip"; gv.HeaderRow.Cells[10].Text = "Operador"; } //gv.HeaderRow.Cells[8].Text = "Control Wip"; gv.HeaderRow.Cells[9].Text = "Papeles"; gv.HeaderRow.Cells[9].Visible = false; //gv.HeaderRow.Cells[10].Text = "Operador"; gv.HeaderRow.Cells[11].Visible = false; gv.HeaderRow.Cells[12].Visible = false; gv.HeaderRow.Cells[13].Visible = false; gv.HeaderRow.Cells[14].Visible = false; gv.HeaderRow.Cells[15].Visible = false; gv.HeaderRow.Cells[16].Visible = false; gv.HeaderRow.Cells[17].Visible = false; gv.HeaderRow.Cells[18].Visible = false; gv.HeaderRow.Cells[19].Visible = false; gv.HeaderRow.Cells[20].Visible = false; int CantPlanSobre = 0; int CantProdSobre = 0; int CantPlanBajo = 0; int CantProdBajo = 0; int TotalPlanificado = 0; for (int contador = 0; contador < gv.Rows.Count; contador++) { GridViewRow row = gv.Rows[contador]; if (Session["Usuario"].ToString().Trim() == "apaillaqueo" || Session["Usuario"].ToString().Trim() == "mandrade") { row.Cells[8].Visible = false; row.Cells[10].Visible = false; } else { row.Cells[8].Text = row.Cells[11].Text; row.Cells[10].Text = row.Cells[9].Text; } //row.Cells[8].Text = row.Cells[11].Text; //row.Cells[10].Text = row.Cells[9].Text; row.Cells[9].Visible = false; row.Cells[9].Text = row.Cells[18].Text; string Maquinagv = row.Cells[7].Text; row.Cells[7].Text = row.Cells[4].Text + "%"; row.Cells[6].Text = row.Cells[17].Text; row.Cells[5].Text = row.Cells[13].Text; row.Cells[4].Text = row.Cells[3].Text; row.Cells[3].Text = row.Cells[2].Text; row.Cells[2].Text = row.Cells[1].Text; row.Cells[1].Text = row.Cells[0].Text; row.Cells[0].Text = Maquinagv; row.Cells[11].Visible = false; row.Cells[12].Visible = false; row.Cells[13].Visible = false; row.Cells[14].Visible = false; row.Cells[15].Visible = false; row.Cells[16].Visible = false; row.Cells[17].Visible = false; row.Cells[18].Visible = false; row.Cells[19].Visible = false; row.Cells[20].Visible = false; TotalPlanificado += Convert.ToInt32(row.Cells[4].Text); if (Convert.ToInt32(row.Cells[5].Text) >= Convert.ToInt32(row.Cells[4].Text)) { CantPlanSobre += Convert.ToInt32(row.Cells[4].Text); CantProdSobre += Convert.ToInt32(row.Cells[5].Text); if (row.Cells[20].Text == "Rotativas") { TotalRotCantPlan += Convert.ToInt32(row.Cells[4].Text); TotalRotCantPlanSobre += Convert.ToInt32(row.Cells[4].Text); TotalRotCantProdSobre += Convert.ToInt32(row.Cells[5].Text); } else { TotalPlaCantPlan += Convert.ToInt32(row.Cells[4].Text); TotalPlaCantPlanSobre += Convert.ToInt32(row.Cells[4].Text); TotalPlaCantProdSobre += Convert.ToInt32(row.Cells[5].Text); } } else { if (row.Cells[20].Text == "Rotativas") { TotalRotCantPlan += Convert.ToInt32(row.Cells[4].Text); CantPlanBajo += Convert.ToInt32(row.Cells[4].Text); TotalRotCantPlanBajo += Convert.ToInt32(row.Cells[4].Text); CantProdBajo += Convert.ToInt32(row.Cells[5].Text); TotalRotCantProdBajo += Convert.ToInt32(row.Cells[5].Text); } else { TotalPlaCantPlan += Convert.ToInt32(row.Cells[4].Text); CantPlanBajo += Convert.ToInt32(row.Cells[4].Text); TotalPlaCantPlanBajo += Convert.ToInt32(row.Cells[4].Text); CantProdBajo += Convert.ToInt32(row.Cells[5].Text); TotalPlaCantProdBajo += Convert.ToInt32(row.Cells[5].Text); } } } string CantidadDif = (CantProdSobre - CantPlanSobre).ToString(); string PorcenProd = (Convert.ToDouble(Convert.ToDouble(CantidadDif) / Convert.ToDouble(CantPlanSobre)) * 100).ToString("N2") + "%"; Label TablaMaquinaTotal = new Label(); string Negativo = ""; if (CantPlanBajo > 0) { string CantidadDifNeg = (CantProdBajo - CantPlanBajo).ToString(); string PorcenProdNeg = (Convert.ToDouble(Convert.ToDouble(CantidadDifNeg) / Convert.ToDouble(CantPlanBajo)) * 100).ToString("N2") + "%"; Negativo = "<tr><td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Bajo</td>" + "<td style='border:1px solid black;'>" + CantPlanBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Bajo</td>" + "<td style='border:1px solid black;'>" + CantProdBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Bajo</td>" + "<td style='border:1px solid black;'>" + CantidadDifNeg + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Bajo</td>" + "<td style='border:1px solid black;'>" + PorcenProdNeg + "</td></tr>"; } TablaMaquinaTotal.Text = "<br/><div align='right'><table><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Total Cant. Plan.</td>" + "<td style='border:1px solid black;'>" + TotalPlanificado.ToString() + "</div></td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Sobre</td>" + "<td style='border:1px solid black;'>" + CantPlanSobre.ToString() + "</div></td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Sobre</td>" + "<td style='border:1px solid black;'>" + CantProdSobre.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Sobre</td>" + "<td style='border:1px solid black;'>" + CantidadDif + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Sobre</td>" + "<td style='border:1px solid black;'>" + PorcenProd.Replace("NaN", "0") + "</td></tr>" + Negativo + "</table></div>"; Label Maquina1 = new Label(); if (contado == 0) { Maquina1.Text = "<div align='left'>" + maquinasProd + " </div><br/>"; } else { Maquina1.Text = "<br/><div align='left'>" + maquinasProd + " </div><br/>"; } form.Controls.Add(Maquina1); form.Controls.Add(gv); form.Controls.Add(TablaMaquinaTotal); contado++; } #endregion Label TablaMaquinaRot = new Label(); TotalRotCantDifSobre = (TotalRotCantProdSobre - TotalRotCantPlanSobre); RotPorceCantDifSobre = Convert.ToDouble(Convert.ToDouble(TotalRotCantDifSobre) / Convert.ToDouble(TotalRotCantPlanSobre)) * 100; TotalRotCantDifBajo = (TotalRotCantPlanBajo - TotalRotCantProdBajo); string RotNegativoBajo = ""; if (TotalRotCantDifBajo > 0) { RotPorceCantDifBajo = Convert.ToDouble(Convert.ToDouble(TotalRotCantDifBajo) / Convert.ToDouble(TotalRotCantPlanBajo)) * 100; RotNegativoBajo = "<tr><td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Bajo</td>" + "<td style='border:1px solid black;'>" + TotalRotCantPlanBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Bajo</td>" + "<td style='border:1px solid black;'>" + TotalRotCantProdBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Bajo</td>" + "<td style='border:1px solid black;'>" + TotalRotCantDifBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Bajo</td>" + "<td style='border:1px solid black;'>" + RotPorceCantDifBajo.ToString() + "%</td></tr>"; } TablaMaquinaRot.Text = "<br/><br/><br/><div align='right'><table><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'colspan ='2'>Rotativa</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Total Cant. Plan.</td>" + "<td style='border:1px solid black;'>" + TotalRotCantPlan.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Sobre</td>" + "<td style='border:1px solid black;'>" + TotalRotCantPlanSobre.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Sobre</td>" + "<td style='border:1px solid black;'>" + TotalRotCantProdSobre.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Sobre</td>" + "<td style='border:1px solid black;'>" + TotalRotCantDifSobre + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Sobre</td>" + "<td style='border:1px solid black;'>" + RotPorceCantDifSobre.ToString("N2").Replace("NaN", "0") + "%</td></tr>" + RotNegativoBajo + "</table></div>"; form.Controls.Add(TablaMaquinaRot); Label TablaMaquinaPla = new Label(); TotalPlaCantDifSobre = (TotalPlaCantProdSobre - TotalPlaCantPlanSobre); TotalPlaCantDifbajo = (TotalPlaCantPlanBajo - TotalPlaCantProdBajo); PlaPorceCantDifSobre = Convert.ToDouble(Convert.ToDouble(TotalPlaCantDifSobre) / Convert.ToDouble(TotalPlaCantPlanSobre)) * 100; string PlaNegativoBajo = ""; if (TotalPlaCantDifbajo > 0) { PlaPorceCantDifBajo = Convert.ToDouble(Convert.ToDouble(TotalPlaCantDifbajo) / Convert.ToDouble(TotalPlaCantPlanBajo)) * 100; PlaNegativoBajo = "<tr><td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Bajo</td>" + "<td style='border:1px solid black;'>" + TotalPlaCantPlanBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Bajo</td>" + "<td style='border:1px solid black;'>" + TotalPlaCantProdBajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Bajo</td>" + "<td style='border:1px solid black;'>" + TotalPlaCantDifbajo.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Bajo</td>" + "<td style='border:1px solid black;'>" + PlaPorceCantDifBajo.ToString() + "%</td></tr>"; } TablaMaquinaPla.Text = "<br/><div align='right'><table><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;' colspan ='2'>Plana</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Total Cant. Plan.</td>" + // colspan ='2' "<td style='border:1px solid black;'>" + TotalPlaCantPlan.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Plan. Sobre</td>" + // colspan ='2' "<td style='border:1px solid black;'>" + TotalPlaCantPlanSobre.ToString() + "</div></td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Cant. Prod. Sobre</td>" + "<td style='border:1px solid black;'>" + TotalPlaCantProdSobre.ToString() + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>Diferencia Sobre</td>" + "<td style='border:1px solid black;'>" + TotalPlaCantDifSobre + "</td></tr><tr>" + "<td colspan ='8'></td><td style='border:1px solid black;'>% Sobre</td>" + "<td style='border:1px solid black;'>" + PlaPorceCantDifSobre.ToString("N2") + "%</td></tr>" + PlaNegativoBajo + "</table></div>"; form.Controls.Add(TablaMaquinaPla); pageToRender.Controls.Add(form); response.Clear(); response.Buffer = true; response.ContentType = "application/vnd.ms-excel"; response.AddHeader("Content-Disposition", "attachment;filename=" + nameReport + ".xls"); response.Charset = "UTF-8"; response.ContentEncoding = Encoding.Default; pageToRender.RenderControl(htw); response.Write(sw.ToString()); response.End(); }
// Render the progress bar // protected override void Render(HtmlTextWriter output) { if (Width.Type != UnitType.Pixel) { throw new ArgumentException("The width must be in pixels"); } int width = (int)Width.Value; if (ImageGeneratorUrl != "") { // a image generate on the fly string borderColor = ""; if (BorderColor != Color.Empty) { borderColor = "&bc=" + ColorTranslator.ToHtml(BorderColor); } output.Write(string.Format("<img src='{0}?w={1}&h={2}&p={3}&fc={4}&bk={5}{6}' border='0' width='{1}' height='{2}'>", ImageGeneratorUrl, width, Height.ToString(), Percentage, ColorTranslator.ToHtml(ForeColor), ColorTranslator.ToHtml(BackColor), borderColor)); } else { // border ?? if (BorderColor != Color.Empty) { output.Write("<table border='0' cellspacing='0' cellpadding='1' bgColor='" + ColorTranslator.ToHtml(BorderColor) + "'><tr><td>"); } if (BarImageUrl == "") { // We render a table // output.Write("<table border='0' cellspacing='0' cellpadding='0' height='" + Height + "' bgColor='" + ColorTranslator.ToHtml(BackColor) + "'><tr>"); int cellWidth = width / cellCount; int curPercentage = 0; int percentageStep = PercentageStep; string cellColor; string cellValue = ""; if (Page.Request.Browser.Browser.ToUpper() == "NETSCAPE") { if (FillImageUrl != "") { cellValue = "<img src='" + FillImageUrl + "' border='0' width='" + cellWidth + "'>"; } else { cellValue = " "; } } // Create the cells for (int i = 0; i < cellCount; i++, curPercentage += percentageStep) { if (curPercentage < percentage) { cellColor = " bgColor='" + ColorTranslator.ToHtml(ForeColor) + "'"; } else { cellColor = ""; } if (i == 0) { output.Write("<td height='" + Height + "' width='" + cellWidth + "'" + cellColor + ">" + cellValue + "</td>"); } else { output.Write("<td width='" + cellWidth + "'" + cellColor + ">" + cellValue + "</td>"); } } output.Write("</tr></table>"); } else { // Use a image as the bar int imageWidth = (int)((percentage / 100.0) * width); output.Write("<table border='0' cellpadding='0' cellSpacing='0' bgColor='" + ColorTranslator.ToHtml(BackColor) + "'><tr><td width='" + width + "'>"); output.Write("<img src='" + BarImageUrl + "' width='" + imageWidth + "' height='" + Height + "'>"); output.Write("</td></tr></table>"); } if (BorderColor != Color.Empty) { output.Write("</td></tr></table>"); } } }
protected override void RenderContents(HtmlTextWriter writer) { EnsureChildControls(); base.RenderContents(writer); }
protected override void Render(HtmlTextWriter w) { this.container.RenderControl(w); }
/// <summary> /// Renders the control as a script tag. /// </summary> /// <param name="writer"> /// The writer. /// </param> public override void RenderControl(HtmlTextWriter writer) { writer.Write(this.BuildHtml()); }
private void RenderBarGraph(BarGraph graph, HtmlTextWriter html) { BarGraphRenderer barGraph = new BarGraphRenderer(Color.White); barGraph.RenderMode = graph.RenderMode; barGraph._regions = graph.Regions; barGraph.SetTitles(graph.xTitle, null); if (graph.yTitle != null) { barGraph.VerticalLabel = graph.yTitle; } barGraph.FontColor = Color.Black; barGraph.ShowData = (graph.Interval == 1); barGraph.VerticalTickCount = graph.Ticks; string[] labels = new string[graph.Items.Count]; string[] values = new string[graph.Items.Count]; for (int i = 0; i < graph.Items.Count; ++i) { ChartItem item = graph.Items[i]; labels[i] = item.Name; values[i] = item.Value.ToString(); } barGraph._interval = graph.Interval; barGraph.CollectDataPoints(labels, values); Bitmap bmp = barGraph.Draw(); string fileName = graph.FileName + ".png"; bmp.Save(Path.Combine(m_OutputDirectory, fileName), ImageFormat.Png); html.Write("<!-- "); html.AddAttribute(HtmlAttr.Href, "#"); html.AddAttribute(HtmlAttr.Onclick, String.Format("javascript:window.open('{0}.html','ChildWindow','width={1},height={2},resizable=no,status=no,toolbar=no')", SafeFileName(FindNameFrom(graph)), bmp.Width + 30, bmp.Height + 80)); html.RenderBeginTag(HtmlTag.A); html.Write(graph.Name); html.RenderEndTag(); html.Write(" -->"); html.AddAttribute(HtmlAttr.Cellpadding, "0"); html.AddAttribute(HtmlAttr.Cellspacing, "0"); html.AddAttribute(HtmlAttr.Border, "0"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Class, "tbl-border"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Cellpadding, "4"); html.AddAttribute(HtmlAttr.Cellspacing, "1"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "header"); html.RenderBeginTag(HtmlTag.Td); html.Write(graph.Name); html.RenderEndTag(); html.RenderEndTag(); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "entry"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, bmp.Width.ToString()); html.AddAttribute(HtmlAttr.Height, bmp.Height.ToString()); html.AddAttribute(HtmlAttr.Src, fileName); html.RenderBeginTag(HtmlTag.Img); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); bmp.Dispose(); }
protected internal override void Render(HtmlTextWriter writer) { SetCallbackProperties(); SetForeColor(); base.Render(writer); }
protected override void Render(HtmlTextWriter output) { output.Write("<font size=" + this.FontSize.ToString() + ">" + this.Text + "</font>"); }
private void RenderReport(Report report, HtmlTextWriter html) { html.AddAttribute(HtmlAttr.Width, report.Width); html.AddAttribute(HtmlAttr.Cellpadding, "0"); html.AddAttribute(HtmlAttr.Cellspacing, "0"); html.AddAttribute(HtmlAttr.Border, "0"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Class, "tbl-border"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Cellpadding, "4"); html.AddAttribute(HtmlAttr.Cellspacing, "1"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "header"); html.RenderBeginTag(HtmlTag.Td); html.Write(report.Name); html.RenderEndTag(); html.RenderEndTag(); bool isNamed = false; for (int i = 0; i < report.Columns.Count && !isNamed; ++i) { isNamed = (report.Columns[i].Name != null); } if (isNamed) { html.RenderBeginTag(HtmlTag.Tr); for (int i = 0; i < report.Columns.Count; ++i) { ReportColumn column = report.Columns[i]; html.AddAttribute(HtmlAttr.Class, "header"); html.AddAttribute(HtmlAttr.Width, column.Width); html.AddAttribute(HtmlAttr.Align, column.Align); html.RenderBeginTag(HtmlTag.Td); html.Write(column.Name); html.RenderEndTag(); } html.RenderEndTag(); } for (int i = 0; i < report.Items.Count; ++i) { ReportItem item = report.Items[i]; html.RenderBeginTag(HtmlTag.Tr); for (int j = 0; j < item.Values.Count; ++j) { if (!isNamed && j == 0) { html.AddAttribute(HtmlAttr.Width, report.Columns[j].Width); } html.AddAttribute(HtmlAttr.Align, report.Columns[j].Align); html.AddAttribute(HtmlAttr.Class, "entry"); html.RenderBeginTag(HtmlTag.Td); if (item.Values[j].Format == null) { html.Write(item.Values[j].Value); } else { html.Write(int.Parse(item.Values[j].Value).ToString(item.Values[j].Format)); } html.RenderEndTag(); } html.RenderEndTag(); } html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); }
public void GenerateInvoicePDF(object sender, EventArgs e) { //Dummy data for Invoice (Bill). string companyName = "ASPSnippets"; int orderNo = 2303; DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[5] { new DataColumn("ProductId", typeof(string)), new DataColumn("Product", typeof(string)), new DataColumn("Price", typeof(int)), new DataColumn("Quantity", typeof(int)), new DataColumn("Total", typeof(int)) }); dt.Rows.Add(101, "Sun Glasses", 200, 5, 1000); dt.Rows.Add(102, "Jeans", 400, 2, 800); dt.Rows.Add(103, "Trousers", 300, 3, 900); dt.Rows.Add(104, "Shirts", 550, 2, 1100); using (StringWriter sw = new StringWriter()) { using (HtmlTextWriter hw = new HtmlTextWriter(sw)) { StringBuilder sb = new StringBuilder(); //Generate Invoice (Bill) Header. sb.Append("<div class='container'><div class='row'> <div class=' well col - md - 4'> <div class='row'> <div class='col - xs - 6 col - sm - 6 col - md - 6'> <address> <strong>Elf Cafe</strong> <br> 2135 Sunset Blvd <br> Los Angeles, CA 90026 <br> <abbr title='Phone'>P:</abbr> (213) 484-6829 </address> </div> <div class='col - xs - 6 col - sm - 6 col - md - 6 text - right'> <p> <em>Date: 1st November, 2013</em> </p> <p> <em>Receipt #: 34522677W</em> </p> </div> </div> <div class='row'> <div class='text - center'> <h1>Receipt</h1> </div> <table class='table table - hover'> <thead> <tr> <th>Product</th> <th>#</th> <th class='text - center'>Price</th> <th class='text - center'>Total</th> </tr> </thead> <tbody> <tr> <td class='col - md - 9'><em>Baked Tart with Thyme and Garlic</em></h4></td> <td class='col - md - 1' style='text - align: center'> 3 </td> <td class='col - md - 1 text - center'>$16</td> <td class='col - md - 1 text - center'>$48</td> </tr> <tr> <td> </td> <td> </td> <td class='text - right'> <p> <strong>Subtotal: </strong> </p> <p> <strong>Tax: </strong> </p></td> <td class='text - center'> <p> <strong>$6.94</strong> </p> <p> <strong>$6.94</strong> </p></td> </tr> <tr> <td> </td> <td> </td> <td class='text - right'><h4><strong>Total: </strong></h4></td> <td class='text - center text - danger'><h4><strong>$31.53</strong></h4></td> </tr> </tbody> </table> </td> </div> </div> </div> </div> "); /* sb.Append("<table width='100%' cellspacing='0' cellpadding='2'>"); * sb.Append("<tr><td align='center' style='background-color: #18B5F0' colspan = '2'><b>Order Sheet</b></td><td align='center' style='background-color: #18B5F0' colspan = '2'><b>Order Sheet</b></td><td align='center' style='background-color: #18B5F0' colspan = '2'><b>Order Sheet</b></td></tr>"); * sb.Append("<tr><td colspan = '2'></td></tr>"); * sb.Append("<tr><td><b>Order No: </b>"); * sb.Append(orderNo); * sb.Append("</td><td align = 'right'><b>Date: </b>"); * sb.Append(DateTime.Now); * sb.Append(" </td></tr>"); * sb.Append("<tr><td colspan = '2'><b>Company Name: </b>"); * sb.Append(companyName); * sb.Append("</td></tr>"); * sb.Append("</table>"); * sb.Append("<br />"); * * //Generate Invoice (Bill) Items Grid. * sb.Append("<table border = '1'>"); * sb.Append("<tr>"); * foreach (DataColumn column in dt.Columns) * { * sb.Append("<th style = 'background-color: #D20B0C;color:#ffffff'>"); * sb.Append(column.ColumnName); * sb.Append("</th>"); * } * sb.Append("</tr>"); * foreach (DataRow row in dt.Rows) * { * sb.Append("<tr>"); * foreach (DataColumn column in dt.Columns) * { * sb.Append("<td>"); * sb.Append(row[column]); * sb.Append("</td>"); * } * sb.Append("</tr>"); * } * sb.Append("<tr><td align = 'right' colspan = '"); * sb.Append(dt.Columns.Count - 1); * sb.Append("'>Total</td>"); * sb.Append("<td>"); * sb.Append(dt.Compute("sum(Total)", "")); * sb.Append("</td>"); * sb.Append("</tr></table>"); */ //Export HTML String as PDF. StringReader sr = new StringReader(sb.ToString()); Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter writer = PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", "attachment;filename=Invoice_" + orderNo + ".pdf"); Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.Write(pdfDoc); Response.End(); } } }
private void RenderPieChart(PieChart chart, HtmlTextWriter html) { PieChartRenderer pieChart = new PieChartRenderer(Color.White); pieChart.ShowPercents = chart.ShowPercents; string[] labels = new string[chart.Items.Count]; string[] values = new string[chart.Items.Count]; for (int i = 0; i < chart.Items.Count; ++i) { ChartItem item = chart.Items[i]; labels[i] = item.Name; values[i] = item.Value.ToString(); } pieChart.CollectDataPoints(labels, values); Bitmap bmp = pieChart.Draw(); string fileName = chart.FileName + ".png"; bmp.Save(Path.Combine(m_OutputDirectory, fileName), ImageFormat.Png); html.Write("<!-- "); html.AddAttribute(HtmlAttr.Href, "#"); html.AddAttribute(HtmlAttr.Onclick, String.Format("javascript:window.open('{0}.html','ChildWindow','width={1},height={2},resizable=no,status=no,toolbar=no')", SafeFileName(FindNameFrom(chart)), bmp.Width + 30, bmp.Height + 80)); html.RenderBeginTag(HtmlTag.A); html.Write(chart.Name); html.RenderEndTag(); html.Write(" -->"); html.AddAttribute(HtmlAttr.Cellpadding, "0"); html.AddAttribute(HtmlAttr.Cellspacing, "0"); html.AddAttribute(HtmlAttr.Border, "0"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Class, "tbl-border"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Cellpadding, "4"); html.AddAttribute(HtmlAttr.Cellspacing, "1"); html.RenderBeginTag(HtmlTag.Table); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "header"); html.RenderBeginTag(HtmlTag.Td); html.Write(chart.Name); html.RenderEndTag(); html.RenderEndTag(); html.RenderBeginTag(HtmlTag.Tr); html.AddAttribute(HtmlAttr.Colspan, "10"); html.AddAttribute(HtmlAttr.Width, "100%"); html.AddAttribute(HtmlAttr.Align, "center"); html.AddAttribute(HtmlAttr.Class, "entry"); html.RenderBeginTag(HtmlTag.Td); html.AddAttribute(HtmlAttr.Width, bmp.Width.ToString()); html.AddAttribute(HtmlAttr.Height, bmp.Height.ToString()); html.AddAttribute(HtmlAttr.Src, fileName); html.RenderBeginTag(HtmlTag.Img); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); html.RenderEndTag(); bmp.Dispose(); }
protected void imgbtnPDF_OnClick(object sender, EventArgs e) { try { Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); string filename = "FCIP_Report" + DateTime.Now.Date.ToString("dd-MM-yyyy") + ".pdf"; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); using (StringWriter sw = new StringWriter()) { HtmlTextWriter hw = new HtmlTextWriter(sw); //To Export all pages gvFCIPLogReport.AllowPaging = false; // this.MilkStorageGrid(); gvFCIPLogReport.HeaderRow.BackColor = Color.White; foreach (TableCell cell in gvFCIPLogReport.HeaderRow.Cells) { cell.BackColor = gvFCIPLogReport.HeaderStyle.BackColor; } foreach (GridViewRow row in gvFCIPLogReport.Rows) { row.BackColor = Color.White; foreach (TableCell cell in row.Cells) { if (row.RowIndex % 2 == 0) { cell.BackColor = gvFCIPLogReport.AlternatingRowStyle.BackColor; } else { cell.BackColor = gvFCIPLogReport.RowStyle.BackColor; } cell.CssClass = "textmode"; List <Control> controls = new List <Control>(); //Add controls to be removed to Generic List foreach (Control control in cell.Controls) { controls.Add(control); } //Loop through the controls to be removed and replace then with Literal foreach (Control control in controls) { switch (control.GetType().Name) { case "HyperLink": cell.Controls.Add(new Literal { Text = (control as HyperLink).Text }); break; case "TextBox": cell.Controls.Add(new Literal { Text = (control as TextBox).Text }); break; case "LinkButton": cell.Controls.Add(new Literal { Text = (control as LinkButton).Text }); break; case "CheckBox": cell.Controls.Add(new Literal { Text = (control as CheckBox).Text }); break; case "RadioButton": cell.Controls.Add(new Literal { Text = (control as RadioButton).Text }); break; } cell.Controls.Remove(control); } } } //gvFCIPLogReport.Columns[0].Visible = false; gvFCIPLogReport.RenderControl(hw); string strSubTitle = "FCIP LOG REPORT"; //string strPath = Request.Url.GetLeftPart(UriPartial.Authority) + "/images/Logo1.gif"; //string content = "<div align='left' style='font-family:verdana;font-size:16px'><img src='" + strPath + "'/></div><div align='center' style='font-family:verdana;font-size:16px'><span style='font-size:16px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationName] + string content = "<div align='center'><img align='left' style='height: 40px; width: 109px' src='" + Session[ApplicationSession.Logo] + "'/><span style='font-size:16px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationName] + "</span><br/><span style='font-size:13px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationAddress] + "</span><br/></div>" + "<div align='center' style='font-family:verdana;font-size:11px'><strong>From Date :</strong>" + DateTime.ParseExact(txtFromDate.Text + " " + txtFromTime.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture) + " <strong> To Date :</strong>" + DateTime.ParseExact(txtToDate.Text + " " + txtToTime.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture) + "</div><br/><div align='center' style='font-family:verdana;font-size:11px'><span style='font-size:11px;color:Maroon;'>" + strSubTitle + "</ span><br/>" + "<br/>" + sw.ToString() + "<br/></div>"; // string style = @"<!--mce:2-->"; StringReader sr = new StringReader(content); Document pdfDoc = new Document(iTextSharp.text.PageSize.A4, 10f, 10f, 10f, 0f); pdfDoc.SetPageSize(iTextSharp.text.PageSize.A4_LANDSCAPE.Rotate()); HTMLWorker htmlparser = new HTMLWorker(pdfDoc); PdfWriter.GetInstance(pdfDoc, Response.OutputStream); pdfDoc.Open(); htmlparser.Parse(sr); pdfDoc.Close(); Response.Write(pdfDoc); gvFCIPLogReport.GridLines = GridLines.None; Response.End(); } } catch (Exception ex) { log.Error("Error", ex); ClientScript.RegisterStartupScript(typeof(Page), "MessagePopUp", "<script>alert('Oops! There is some technical Problem. Contact to your Administrator.');</script>"); } }
protected void DrawGridFooter(HtmlTextWriter output, Control ctl) { output.Write("<td colspan='2' rowspan='5'>预测方法:<br>用鼠标点击<br>方格即可显示<br>为开奖号色</td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'onClick=Style(this,'#DD0000','#FCDFC5') style='color:#FCDFC5'>质</td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'onClick=Style(this,'#DD0000','#FCDFC5') style='color:#FCDFC5'>合</td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); for (int i = 0; i < 3; i++) { output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'onClick=Style(this,'#DD0000','#DDFFE6') style='color:#DDFFE6'>质</td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'onClick=Style(this,'#DD0000','#DDFFE6') style='color:#DDFFE6'>合</td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'onClick=Style(this,'#DD0000','#C1E7FF') style='color:#C1E7FF'>质</td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'onClick=Style(this,'#DD0000','#C1E7FF') style='color:#C1E7FF'>合</td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); } for (int j = 0; j < 4; j++) { output.Write("<tr align='center' valign='middle'>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'onClick=Style(this,'#DD0000','#FCDFC5') style='color:#FCDFC5'>质</td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'onClick=Style(this,'#DD0000','#FCDFC5') style='color:#FCDFC5'>合</td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); for (int i = 0; i < 3; i++) { output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'onClick=Style(this,'#DD0000','#DDFFE6') style='color:#DDFFE6'>质</td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'onClick=Style(this,'#DD0000','#DDFFE6') style='color:#DDFFE6'>合</td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'onClick=Style(this,'#DD0000','#C1E7FF') style='color:#C1E7FF'>质</td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'onClick=Style(this,'#DD0000','#C1E7FF') style='color:#C1E7FF'>合</td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); } } output.Write("<tr align='center' vlign = 'middle'>"); output.Write("<td> </td>"); output.Write("<td> </td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'><font color='DD0000'>质</font></td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); output.Write("<td bgcolor='#FCDFC5'><font color='DD0000'>合</font></td>"); output.Write("<td bgcolor='#FCDFC5'> </td>"); for (int k = 0; k < 3; k++) { output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'><font color='DD0000'>质</font></td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#DDFFE6'><font color='DD0000'>合</font></td>"); output.Write("<td bgcolor='#DDFFE6'> </td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'><font color='DD0000'>质</font></td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); output.Write("<td bgcolor='#C1E7FF'><font color='DD0000'>合</font></td>"); output.Write("<td bgcolor='#C1E7FF'> </td>"); } output.Write("<tr align='center' vlign='center'>"); output.Write("<td>期 数</td>"); output.Write("<td>开奖号码</td>"); output.Write("<td colspan ='5'bgcolor='#FFC9C8'>第一位</td>"); output.Write("<td colspan ='5'bgcolor='#DDFFE6'>第二位</td>"); output.Write("<td colspan ='5'bgcolor='#C1E7FF'>第三位</td>"); output.Write("<td colspan ='5'bgcolor='#C1E7FF'>第四位</td>"); output.Write("<td colspan ='5'bgcolor='#C1E7FF'>第五位</td>"); output.Write("<td colspan ='5'bgcolor='#C1E7FF'>第六位</td>"); output.Write("<td colspan ='5'bgcolor='#C1E7FF'>第七位</td>"); }
public abstract void RenderBackUrls(HtmlTextWriter writer);
protected void imgbtnExcel_OnClick(object sender, EventArgs e) { Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; Response.ContentEncoding = System.Text.Encoding.Unicode; Response.BinaryWrite(System.Text.Encoding.Unicode.GetPreamble()); string filename = "FCIPLog_Report" + DateTime.Now.Date.ToString("dd-MM-yyyy") + ".xls"; Response.AddHeader("content-disposition", "attachment;filename=" + filename); Response.Cache.SetCacheability(HttpCacheability.NoCache); StringWriter sw = new StringWriter(); HtmlTextWriter hw = new HtmlTextWriter(sw); gvFCIPLogReport.AllowPaging = false; gvFCIPLogReport.GridLines = GridLines.Both; foreach (TableCell cell in gvFCIPLogReport.HeaderRow.Cells) { cell.BackColor = gvFCIPLogReport.HeaderStyle.BackColor; } foreach (GridViewRow row in gvFCIPLogReport.Rows) { row.BackColor = Color.White; foreach (TableCell cell in row.Cells) { if (row.RowIndex % 2 == 0) { cell.BackColor = gvFCIPLogReport.AlternatingRowStyle.BackColor; } else { cell.BackColor = gvFCIPLogReport.RowStyle.BackColor; } cell.CssClass = "textmode"; List <Control> controls = new List <Control>(); //Add controls to be removed to Generic List foreach (Control control in cell.Controls) { controls.Add(control); } //Loop through the controls to be removed and replace then with Literal foreach (Control control in controls) { switch (control.GetType().Name) { case "HyperLink": cell.Controls.Add(new Literal { Text = (control as HyperLink).Text }); break; case "TextBox": cell.Controls.Add(new Literal { Text = (control as TextBox).Text }); break; case "LinkButton": cell.Controls.Add(new Literal { Text = (control as LinkButton).Text }); break; case "CheckBox": cell.Controls.Add(new Literal { Text = (control as CheckBox).Text }); break; case "RadioButton": cell.Controls.Add(new Literal { Text = (control as RadioButton).Text }); break; } cell.Controls.Remove(control); } } } gvFCIPLogReport.RenderControl(hw); string strSubTitle = "FCIP LOG REPORT"; //string strPath = Request.Url.GetLeftPart(UriPartial.Authority) + "/images/Logo1.gif"; //string content = "<div align='left' style='font-family:verdana;font-size:16px'><img src='" + strPath + "'/></div><div align='center' style='font-family:verdana;font-size:16px'><span style='font-size:16px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationName] + string content = "<div align='center'><img align='left' style='height: 40px; width: 109px' src='" + Session[ApplicationSession.Logo] + "'/><span style='font-size:16px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationName] + "</span><br/><span style='font-size:13px;font-weight:bold;color:Black;'>" + Session[ApplicationSession.OrganisationAddress] + "</span><br/></div>" + "<div align='center' style='font-family:verdana;font-size:11px'><strong>From Date :</strong>" + DateTime.ParseExact(txtFromDate.Text + " " + txtFromTime.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture) + " <strong> To Date :</strong>" + DateTime.ParseExact(txtToDate.Text + " " + txtToTime.Text, "dd/MM/yyyy HH:mm:ss", CultureInfo.InvariantCulture) + "</div><br/><div align='center' style='font-family:verdana;font-size:11px'><span style='font-size:11px;color:Maroon;'>" + strSubTitle + "</ span><br/>" + "<br/>" + sw.ToString() + "<br/></div>"; string style = @"<!--mce:2-->"; Response.Write(style); Response.Output.Write(content); //gvOEEReport.GridLines = GridLines.None; Response.Flush(); Response.Clear(); Response.End(); }
/// <summary> /// Overridden and Empty so that span tags are not written /// </summary> /// <param name="writer"></param> public override void RenderEndTag(HtmlTextWriter writer) { }
protected override void Render(HtmlTextWriter writer) { if (HttpContext.Current == null) { writer.Write("[" + this.ID + "]"); return; } SiteSettings siteSettings = CacheHelper.GetCurrentSiteSettings(); if (siteSettings == null) { return; } if (renderAsListItem) { if (Page.Request.IsAuthenticated) { //writer.Write("<li class='" + listItemCSS + "'>"); writer.WriteBeginTag("li"); writer.WriteAttribute("class", listItemCSS); writer.Write(HtmlTextWriter.TagRightChar); } else { //writer.Write("<li class='" + anonymousListItemCSS + "'>"); writer.WriteBeginTag("li"); writer.WriteAttribute("class", anonymousListItemCSS); writer.Write(HtmlTextWriter.TagRightChar); } } if (UseLeftSeparator) { writer.Write("<span class='accent'>|</span>"); } string urlToUse = SiteUtils.GetNavigationSiteRoot(); if ((!siteSettings.UseSslOnAllPages) && (Page.Request.IsSecureConnection)) { urlToUse = urlToUse.Replace("https", "http"); } if (CssClass.Length == 0) { CssClass = "sitelink"; } if (overrideUrl.Length > 0) { urlToUse = urlToUse + overrideUrl.Replace("~/", "/"); } else { if (siteSettings.SiteFolderName.Length > 0) { urlToUse += "/Default.aspx"; } } if (useSiteTitle) { writer.WriteBeginTag("a"); writer.WriteAttribute("class", CssClass); //writer.WriteAttribute("title", siteSettings.SiteName); writer.WriteAttribute("href", Page.ResolveUrl(urlToUse)); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteEncodedText(siteSettings.SiteName); writer.WriteEndTag("a"); } else { writer.WriteBeginTag("a"); writer.WriteAttribute("class", CssClass); //writer.WriteAttribute("title", Resource.HomePageLink); writer.WriteAttribute("href", Page.ResolveUrl(urlToUse)); writer.Write(HtmlTextWriter.TagRightChar); writer.WriteEncodedText(Resource.HomePageLink); writer.WriteEndTag("a"); } if (renderAsListItem) { writer.WriteEndTag("li"); } }
/// <summary> /// Writes the <see cref="T:System.Web.UI.WebControls.CompositeControl" /> content to the specified <see cref="T:System.Web.UI.HtmlTextWriter" /> object, for display on the client. /// </summary> /// <param name="writer">An <see cref="T:System.Web.UI.HtmlTextWriter" /> that represents the output stream to render HTML content on the client.</param> public override void RenderControl(HtmlTextWriter writer) { DataFilterComponent component = null; string clientFormatString = string.Empty; if (!string.IsNullOrWhiteSpace(FilterEntityTypeName)) { component = Rock.Reporting.DataFilterContainer.GetComponent(FilterEntityTypeName); if (component != null) { clientFormatString = string.Format("if ($(this).find('.filter-view-state').children('i').hasClass('fa-chevron-up')) {{ var $article = $(this).parents('article:first'); var $content = $article.children('div.panel-body'); $article.find('div.filter-item-description:first').html({0}); }}", component.GetClientFormatSelection(FilteredEntityType)); } } if (component == null) { hfExpanded.Value = "True"; } writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel panel-widget filter-item"); writer.RenderBeginTag("article"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "panel-heading clearfix"); if (!string.IsNullOrEmpty(clientFormatString)) { writer.AddAttribute(HtmlTextWriterAttribute.Onclick, clientFormatString); } writer.RenderBeginTag("header"); writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-expanded"); hfExpanded.RenderControl(writer); writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-left"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-description"); if (Expanded) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.Write(component != null ? component.FormatSelection(FilteredEntityType, Selection) : "Select Filter"); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "filter-item-select"); if (!Expanded) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write("Filter Type "); writer.RenderEndTag(); ddlFilterType.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "pull-right"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Class, "btn btn-link btn-xs filter-view-state"); writer.RenderBeginTag(HtmlTextWriterTag.A); writer.AddAttribute(HtmlTextWriterAttribute.Class, Expanded ? "fa fa-chevron-up" : "fa fa-chevron-down"); writer.RenderBeginTag(HtmlTextWriterTag.I); writer.RenderEndTag(); writer.RenderEndTag(); writer.Write(" "); lbDelete.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); writer.AddAttribute("class", "panel-body"); if (!Expanded) { writer.AddStyleAttribute(HtmlTextWriterStyle.Display, "none"); } writer.RenderBeginTag(HtmlTextWriterTag.Div); if (component != null) { component.RenderControls(FilteredEntityType, this, writer, filterControls); } writer.RenderEndTag(); writer.RenderEndTag(); }
protected override void Render(HtmlTextWriter writer) { if (OverrideRender) { StringBuilder sbOut = new StringBuilder(); using (StringWriter swOut = new StringWriter(sbOut, CultureInfo.InvariantCulture)) { UTF8Encoding enc = new UTF8Encoding(true); swOut.Write(Encoding.UTF8.GetString(enc.GetPreamble())); HtmlTextWriter htwOut = new HtmlTextWriter(swOut); base.Render(htwOut); string sOut = sbOut.ToString(); string szTempPath = Path.GetTempPath(); string szFileRoot = Guid.NewGuid().ToString(); string szOutputHtm = szTempPath + szFileRoot + ".htm"; string szOutputPDF = szTempPath + szFileRoot + ".pdf"; File.WriteAllText(szOutputHtm, sbOut.ToString()); const string szWkTextApp = "c:\\program files\\wkhtmltopdf\\bin\\wkhtmltopdf.exe"; // TODO: this needs to be in a config file string szArgs = PageOptions.WKHtmlToPDFArguments(szOutputHtm, szOutputPDF); Process p = null; using (p = new Process()) { try { p.StartInfo = new ProcessStartInfo(szWkTextApp, szArgs) { UseShellExecute = true }; // for some reason, wkhtmltopdf runs better in shell exec than without. p.Start(); bool fResult = p.WaitForExit(120000); // wait up to 2 minutes if (!fResult || !File.Exists(szOutputPDF)) { util.NotifyAdminEvent("Error saving PDF", String.Format(CultureInfo.CurrentCulture, "User: {0}\r\nOptions:\r\n{1}\r\n\r\nQuery:{2}\r\n", CurrentUser.UserName, JsonConvert.SerializeObject(PageOptions), JsonConvert.SerializeObject(PrintOptions1.Options)), ProfileRoles.maskSiteAdminOnly); Response.Redirect(Request.Url.PathAndQuery + (Request.Url.PathAndQuery.Contains("?") ? "&" : "?") + "pdfErr=1"); } else { Page.Response.Clear(); Page.Response.ContentType = "application/pdf"; Response.AddHeader("content-disposition", String.Format(CultureInfo.CurrentCulture, @"attachment;filename=""{0}.pdf""", CurrentUser.UserFullName)); Response.WriteFile(szOutputPDF); Page.Response.Flush(); // See http://stackoverflow.com/questions/20988445/how-to-avoid-response-end-thread-was-being-aborted-exception-during-the-exce for the reason for the next two lines. Page.Response.SuppressContent = true; // Gets or sets a value indicating whether to send HTTP content to the client. HttpContext.Current.ApplicationInstance.CompleteRequest(); // Causes ASP.NET to bypass all events and filtering in the HTTP pipeline chain of execution and directly execute the EndRequest event. } } catch (MyFlightbookException) { throw; } finally { File.Delete(szOutputHtm); File.Delete(szOutputPDF); if (p != null && !p.HasExited) { p.Kill(); } } } } } else { base.Render(writer); } }
protected override void Render(HtmlTextWriter writer) { Response.ContentType = "application/atomsvc+xml"; base.Render(writer); }
// /// <summary> // /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering. // /// </summary> // protected override void CreateChildControls() // { // if (ChildControlsCreated) // { // return; // } // Controls.Clear(); // //Instantiate the Header template (if exists) // if (m_headerTemplate != null) // { // Control headerItem = new Control(); // m_headerTemplate.InstantiateIn(headerItem); // Controls.Add(headerItem); // } // //Instantiate the Footer template (if exists) // if (m_footerTemplate != null) // { // Control footerItem = new Control(); // m_footerTemplate.InstantiateIn(footerItem); // Controls.Add(footerItem); // } // // ChildControlsCreated = true; // } /// <summary> /// Overridden and Empty so that span tags are not written /// </summary> /// <param name="writer"></param> public override void RenderBeginTag(HtmlTextWriter writer) { }
protected override void Render(HtmlTextWriter output) { if (StyleInfoList == null || StyleInfoList.Count == 0 || Attributes == null) { return; } var pageScripts = new NameValueCollection(); var builder = new StringBuilder(); foreach (var styleInfo in StyleInfoList) { if (StringUtils.EqualsIgnoreCase(styleInfo.AttributeName, ContentAttribute.Title)) { continue; } string extra; var value = BackgroundInputTypeParser.Parse(SiteInfo, ChannelId, styleInfo, Attributes, pageScripts, out extra); if (string.IsNullOrEmpty(value) && string.IsNullOrEmpty(extra)) { continue; } if (styleInfo.InputType == InputType.TextEditor) { var commands = WebUtils.GetTextEditorCommands(SiteInfo, styleInfo.AttributeName); builder.Append($@" <div class=""form-group form-row""> <label class=""col-sm-1 col-form-label text-right"">{styleInfo.DisplayName}</label> <div class=""col-sm-10""> {commands} <div class=""m-t-10""> {value} </div> </div> <div class=""col-sm-1""> {extra} </div> </div>"); } else { var html = $@" <div class=""form-group form-row""> <label class=""col-sm-1 col-form-label text-right"">{styleInfo.DisplayName}</label> <div class=""col-sm-6""> {value} </div> <div class=""col-sm-5""> {extra} </div> </div>"; if (styleInfo.InputType == InputType.Customize) { var eventArgs = new ContentFormLoadEventArgs(SiteInfo.Id, ChannelId, ContentId, Attributes, styleInfo.AttributeName, html); foreach (var service in PluginManager.Services) { try { html = service.OnContentFormLoad(eventArgs); } catch (Exception ex) { LogUtils.AddErrorLog(service.PluginId, ex, nameof(IService.ContentFormLoad)); } } } builder.Append(html); } } output.Write(builder.ToString()); foreach (string key in pageScripts.Keys) { output.Write(pageScripts[key]); } }
/// <summary> /// Renders the child controls used to display and edit the filter settings for HTML presentation. /// </summary> /// <param name="entityType">The System Type of the entity to which the filter will be applied.</param> /// <param name="filterControl">The control that serves as the container for the controls being rendered.</param> /// <param name="writer">The writer being used to generate the HTML for the output page.</param> /// <param name="controls">The model representation of the child controls for this component.</param> public override void RenderControls(Type entityType, FilterField filterControl, HtmlTextWriter writer, Control[] controls) { var dvpDataView = controls.GetByName <DataViewItemPicker>(_CtlDataView); var ddlCompare = controls.GetByName <RockDropDownList>(_CtlComparison); var nbValue = controls.GetByName <NumberBox>(_CtlMemberCount); dvpDataView.RenderControl(writer); // Comparison Row writer.AddAttribute("class", "row form-row field-criteria d-flex flex-wrap align-items-end"); writer.RenderBeginTag(HtmlTextWriterTag.Div); // Comparison Type writer.AddAttribute("class", "col-xs-12 col-md-4"); writer.RenderBeginTag(HtmlTextWriterTag.Div); ddlCompare.RenderControl(writer); writer.RenderEndTag(); // Comparison Value writer.AddAttribute("class", "col-xs-12 col-md-8 vertical-align-bottom"); writer.RenderBeginTag(HtmlTextWriterTag.Div); nbValue.RenderControl(writer); writer.RenderEndTag(); writer.RenderEndTag(); }
/// <summary> /// RenderEditMode renders the Edit mode of the control /// </summary> /// <param name="writer">A HtmlTextWriter.</param> /// <history> /// [cnurse] 02/27/2006 created /// </history> protected override void RenderEditMode(HtmlTextWriter writer) { //Render div writer.AddAttribute(HtmlTextWriterAttribute.Class, "dnnLeft"); writer.RenderBeginTag(HtmlTextWriterTag.Div); //Render the Select Tag writer.AddAttribute(HtmlTextWriterAttribute.Name, UniqueID); writer.RenderBeginTag(HtmlTextWriterTag.Select); //Render None selected option //Add the Value Attribute writer.AddAttribute(HtmlTextWriterAttribute.Value, Null.NullString); if (StringValue == Null.NullString) { //Add the Selected Attribute writer.AddAttribute(HtmlTextWriterAttribute.Selected, "selected"); } writer.RenderBeginTag(HtmlTextWriterTag.Option); writer.Write(Localization.GetString("Not_Specified", Localization.SharedResourceFile)); writer.RenderEndTag(); int languageCount = 0; switch (ListType) { case LanguagesListType.All: CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.SpecificCultures); Array.Sort(cultures, new CultureInfoComparer(DisplayMode)); foreach (CultureInfo culture in cultures) { RenderOption(writer, culture); } languageCount = cultures.Length; break; case LanguagesListType.Supported: Dictionary <string, Locale> cultures1 = LocaleController.Instance.GetLocales(Null.NullInteger); foreach (Locale language in cultures1.Values) { RenderOption(writer, CultureInfo.CreateSpecificCulture(language.Code)); } languageCount = cultures1.Count; break; case LanguagesListType.Enabled: Dictionary <string, Locale> cultures2 = LocaleController.Instance.GetLocales(PortalSettings.PortalId); foreach (Locale language in cultures2.Values) { RenderOption(writer, CultureInfo.CreateSpecificCulture(language.Code)); } languageCount = cultures2.Count; break; } //Close Select Tag writer.RenderEndTag(); if (StringValue == Null.NullString && languageCount > 1) { writer.WriteBreak(); writer.AddAttribute(HtmlTextWriterAttribute.Class, "dnnFormMessage dnnFormError"); writer.RenderBeginTag(HtmlTextWriterTag.Span); writer.Write(Localization.GetString("LanguageNotSelected", Localization.SharedResourceFile)); writer.RenderEndTag(); } //Render break writer.Write("<br />"); //Render Span writer.AddAttribute(HtmlTextWriterAttribute.Class, "dnnFormRadioButtons"); writer.RenderBeginTag(HtmlTextWriterTag.Span); //Render Button Row RenderModeButtons(writer); //close span writer.RenderEndTag(); //close div writer.RenderEndTag(); }
} // RenderView public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList) { string formName = "editFlashObject_" + page.Id.ToString() + identifier.ToString() + langToRenderFor.shortCode; FlashObjectDb db = (new FlashObjectDb()); FlashObjectData flashObject = db.getFlashObject(page, identifier, true); StringBuilder html = new StringBuilder(); // ------- CHECK THE FORM FOR ACTIONS string action = Hatfield.Web.Portal.PageUtils.getFromForm(formName + "_FlashObjectAction", ""); if (action.Trim().ToLower() == "saveflashobject") { flashObject.SWFPath = PageUtils.getFromForm(formName + "SWFPath", ""); flashObject.DisplayWidth = PageUtils.getFromForm(formName + "displayWidth", FlashObject.DefaultDisplayWidth); flashObject.DisplayHeight = PageUtils.getFromForm(formName + "displayHeight", FlashObject.DefaultDisplayHeight); bool b = db.saveUpdatedFlashObject(page, identifier, flashObject); if (!b) { html.Append("Error: Flash Object not saved - database error<p><p>"); } } // ------- START RENDERING // note: no need to put in the <form></form> tags. html.Append("<table>"); html.Append("<tr><td>"); html.Append("Flash (SWF) Object:"); html.Append("</td><td>"); string JSCallbackFunctionName = formName + "_selectPath"; StringBuilder js = new StringBuilder(); js.Append("function " + JSCallbackFunctionName + "(selText, selVal) { " + Environment.NewLine); // html.Append("alert(selVal);" + Environment.NewLine); js.Append(" var selectBox = document.getElementById('" + formName + "SWFPath'); " + Environment.NewLine); js.Append(" var found= false; " + Environment.NewLine); js.Append(" for (var i =0; i < selectBox.options.length; i++) {" + Environment.NewLine); js.Append(" if (selectBox.options[i].text == selText){ " + Environment.NewLine); js.Append(" selectBox.options[i].selected = true; found = true; " + Environment.NewLine); js.Append(" } // if" + Environment.NewLine); js.Append(" } // for" + Environment.NewLine); js.Append(" if (!found) { " + Environment.NewLine); js.Append(" var newOption = new Option(selText,selVal); " + Environment.NewLine); js.Append(" selectBox.options[selectBox.options.length]= newOption;" + Environment.NewLine); js.Append(" newOption.selected = true; " + Environment.NewLine); js.Append(" } // if ! found" + Environment.NewLine); js.Append("}" + Environment.NewLine); page.HeadSection.AddJSStatements(js.ToString()); string SWFPathDropDownHtml = getSWFPathDropdown(formName + "SWFPath", flashObject); html.Append(SWFPathDropDownHtml); string onclick = "window.open(this.href, 'newWin', 'resizable,height=" + CmsContext.UserInterface.FlashObjectBrowser.PopupHeight + ",width=" + CmsContext.UserInterface.FlashObjectBrowser.PopupWidth + "'); return false;"; html.Append(" <a href=\"" + CmsContext.UserInterface.FlashObjectBrowser.getUrl(JSCallbackFunctionName) + "\" onclick=\"" + onclick + "\">browse for flash file</a>"); html.Append("</td></tr>"); html.Append("<tr><td>"); html.Append("Width:"); html.Append("</td><td>"); html.Append(PageUtils.getInputTextHtml(formName + "displayWidth", formName + "displayWidth", flashObject.DisplayWidth.ToString(), 7, 5)); html.Append("<br><em>values < 1 will not display the SWF</em>"); html.Append("</td></tr>"); html.Append("<tr><td>"); html.Append("Height:"); html.Append("</td><td>"); html.Append(PageUtils.getInputTextHtml(formName + "displayHeight", formName + "displayHeight", flashObject.DisplayHeight.ToString(), 7, 5)); html.Append("<br><em>values < 1 will not display the SWF</em>"); html.Append("</td></tr>"); html.Append("</table>"); // -- hidden field actions html.Append("<input type=\"hidden\" name=\"" + formName + "_FlashObjectAction\" value=\"saveflashobject\">"); writer.WriteLine(html.ToString()); }