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

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

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

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

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

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

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

            }
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            string rpthtml = "";

            if (hidcurrentview.Value == "detail")
            {
                dsexcel = getmodulesummary();
                rpthtml = binddetailheader("excel");

                for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
                {
                    rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["title"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["description"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["numoftasks"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalesthours"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["percomplete"].ToString() +
                              "</td></tr>";
                }
            }
            else
            {
                fillgrid();
                rpthtml = bindlistviewheader("excel");

                for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
                {
                    rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["projectCode"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["projectname"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["numofmodules"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["totalesthours"].ToString()
                              + "</td><td>" + dsexcel.Tables[0].Rows[i]["percomplete"].ToString()
                              + "</td></tr>";
                }
            }
            HtmlGenericControl divgen = new HtmlGenericControl();

            divgen.InnerHtml = rpthtml;

            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=\"HCLLPProjectSummaryReport.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
        public void ASPXToPDF(HtmlGenericControl objhtml)
        {
            string fileName = "AsignacionFolios.pdf";
            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.Clear();

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

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

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

            HttpContext.Current.Response.ContentType = "application/pdf";
            HttpContext.Current.Response.AddHeader("content-disposition", "attachment;filename=" + fileName);
            HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
            HttpContext.Current.Response.Write(pdfDoc);
            HttpContext.Current.Response.End();
        }
Exemplo n.º 5
0
    /// <summary>
    /// 导入数据,保存文档
    /// </summary>
    /// <param name="tab"></param>
    /// <param name="fileName"></param>
    /// <param name="typeName"></param>
    /// <param name="styleText"></param>
    private void TableExport(System.Web.UI.HtmlControls.HtmlGenericControl tab, string fileName, string typeName, bool isFireFox)
    {
        System.Web.HttpResponse httpResponse = _InvokePage.Response;
        httpResponse.Clear();
        httpResponse.Buffer = true;

        httpResponse.Charset = "gb2312";// "GB2312";
        //Response.Charset = "UTF-8";
        httpResponse.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312>");

        if (isFireFox == true)
        {
            fileName = "\"" + fileName + "\"";
            httpResponse.AppendHeader("Content-Disposition", "attachment;filename=" + fileName);
        }
        else
        {
            httpResponse.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8).ToString());
        }

        httpResponse.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
        httpResponse.ContentType     = typeName;
        _InvokePage.EnableViewState  = false;
        StringWriter tw = new StringWriter();

        System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
        tab.RenderControl(hw);
        // httpResponse.Write(styleText);
        httpResponse.Write(tw.ToString());
        httpResponse.End();
    }
Exemplo n.º 6
0
 protected override void RenderContents(HtmlTextWriter output)
 {
     HtmlGenericControl ctrl = new HtmlGenericControl("PRE");
     ctrl.Attributes["class"] = CssClass;
     ctrl.InnerText = Text;
     ctrl.RenderControl(output);
 }
Exemplo n.º 7
0
 public static string GetHtml(HtmlGenericControl control)
 {
     StringBuilder s = new StringBuilder();
     HtmlTextWriter tw = new HtmlTextWriter(new StringWriter(s));
     control.RenderControl(tw);
     tw.Flush();
     return s.ToString();
 }
Exemplo n.º 8
0
        protected void RenderListEntry(String title, HtmlGenericControl value)
        {
            Writer.RenderBeginTag(HtmlTextWriterTag.Dt);
            Writer.Write(title);
            Writer.RenderEndTag();

            value.RenderControl(Writer);
        }
Exemplo n.º 9
0
        protected void exportsummary()
        {
            fillgrid();
            if (dsexcel != null)
            {
                if (dsexcel.Tables[0].Rows.Count > 0)
                {
                    string rpthtml = bindheader("excel");
                    rpthtml = rpthtml + @"<table width='100%' cellpadding='5' cellspacing='0' style='font-family: Calibri;   font-size: 12px; text-align: left;' border='0'>
<tr><td colspan='5' align='center'>Configuration Report</td> </tr>
<tr><td colspan='5'>&nbsp;</td></tr>
                         
  <tr style='font-weight: bold; background: #395ba4; color: #ffffff;'>
 <td width='100px' align='left'>S.No.</td>
 <td>Server ID</td>
 <td>Server Name</td>
 <td>Client Name </td>
 <td>Domain</td>                                                        
</tr>";
                    for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
                    {
                        rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["ServerCode"].ToString() +
                                  "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["ServerName"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["clientname"].ToString() +
                                  "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["domain"].ToString() + "</td></tr>";
                    }

                    HtmlGenericControl divgen = new HtmlGenericControl();


                    divgen.InnerHtml = rpthtml;
                    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=\"ConfigurationReport.xls\"");

                    // create a string writer
                    using (StringWriter sw = new StringWriter())
                    {
                        using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                        {
                            System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                            dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                            dv.InnerHtml = divgen.InnerHtml.Replace("colspan='7'", "colspan='9'");
                            //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                            dv.RenderControl(htw);
                            response.Write(sw.ToString());
                            response.End();
                        }
                    }
                }
            }
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            objpayroll.nid         = "";
            objpayroll.action      = "getreport";
            objpayroll.companyid   = Session["companyid"].ToString();
            objpayroll.Leavetypeid = hidreportype.Value;
            //NOTE: here we are using "Date" param to pass "Month" and "NumOfDays" to pass "Year"
            objpayroll.RequestDate = hidmonth.Value;
            objpayroll.NumofDays   = hidyear.Value;
            objpayroll.Status      = "Excel";

            ds = objpayroll.LeaveRequest();

            string rpthtml = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                rpthtml = ds.Tables[0].Rows[0]["description"].ToString();
            }
            string rptname = "LeaveReport.xls";

            if (hidreportype.Value == "Monthly Report")
            {
                rptname = "LeaveMonthlyReport-" + hidmonth.Value + "-" + hidyear.Value;
            }
            else
            {
                rptname = "LeaveYearlyReport-" + hidyear.Value;
            }
            HtmlGenericControl divgen = new HtmlGenericControl();


            divgen.InnerHtml = rpthtml;
            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=\"LeaveReport.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

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

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

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

                    divWrapperControl.Controls.Add(divMapControl);

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

                    HtmlGenericControl scriptControl = new HtmlGenericControl("script");
                    scriptControl.Attributes.Add("type", "text/javascript");
                    scriptControl.InnerHtml = string.Format(@"$(document).ready(function(){{
                                                    $('#map-{0}').GoogleMapEditor($.extend({{}},{1},{{dataChange:function(sender, data){{ $(sender.container).next().next().val(data); }}}}));}});", id, map.ToJsonString());
                    divWrapperControl.Controls.Add(scriptControl);
                    divWrapperControl.RenderControl(htmlWriter);
                    sbControlHtml.Append(stringWriter.ToString());
                    divWrapperControl.Dispose();
                }
            }
            return new MvcHtmlString(sbControlHtml.ToString());
        }
Exemplo n.º 12
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            fillgrid();
            string rpthtml = bindheader("excel");

            for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            {
                string time = "", remark = "&nbsp;";

                if (dsexcel.Tables[0].Rows[i]["time"] != null && dsexcel.Tables[0].Rows[i]["time"].ToString() != "")
                {
                    time = " " + dsexcel.Tables[0].Rows[i]["time"].ToString();
                }
                if (dsexcel.Tables[0].Rows[i]["remark"] != null && dsexcel.Tables[0].Rows[i]["remark"].ToString() != "")
                {
                    remark = dsexcel.Tables[0].Rows[i]["remark"].ToString();
                }

                rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["date"].ToString() + time +
                          "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["empname"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["clientname"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["projectname"].ToString() + "</td>" +
                          "<td>" + dsexcel.Tables[0].Rows[i]["status"].ToString() + "</td><td>"
                          + dsexcel.Tables[0].Rows[i]["remark"].ToString() + "</td></tr>";
            }

            HtmlGenericControl divgen = new HtmlGenericControl();


            divgen.InnerHtml = rpthtml;
            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=\"ScheduleReportByEmployeeAndClient.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 13
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            fillgrid();
            string rpthtml  = bindheader("excel");
            string strcolor = "";

            for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            {
                if (i % 2 == 0)
                {
                    strcolor = " style='background-color:#E4DFEC;' ";
                }
                else
                {
                    strcolor = " style='background-color:#ffffff;' ";
                }


                rpthtml = rpthtml + "<tr " + strcolor + "><td valign='top' style='border:solid 1px #8064A2;'><b>" + dsexcel.Tables[0].Rows[i]["clientname"].ToString() +
                          "</b></td>" + "<td valign='top' style='border:solid 1px #8064A2;'>" + dsexcel.Tables[0].Rows[i]["projectcode"].ToString() + "</td>" + "<td style='border:solid 1px #8064A2;' valign='top'>" + dsexcel.Tables[0].Rows[i]["scheduletype"].ToString() + "</td>" + "<td style='border:solid 1px #8064A2;' valign='top'>" + dsexcel.Tables[0].Rows[i]["fromdate"].ToString() + "</td>" + "<td  valign='top' style='border:solid 1px #8064A2;'>" + dsexcel.Tables[0].Rows[i]["todate"].ToString() + "</td>" + "<td valign='top' style='border:solid 1px #8064A2;'>" + dsexcel.Tables[0].Rows[i]["staff"].ToString() + "</td>" +
                          "<td style='border:solid 1px #8064A2;' valign='top' >" + dsexcel.Tables[0].Rows[i]["status"].ToString() + "</td></tr>";
            }

            HtmlGenericControl divgen = new HtmlGenericControl();


            divgen.InnerHtml = rpthtml;
            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=\"ScheduleReportbyClient.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 14
0
        private void ProcessRequest(HttpContext context)
        {
            HtmlGenericControl html = new HtmlGenericControl("html");
            HtmlGenericControl body = new HtmlGenericControl("body");
            GridView grid = BuildPersonGridView();

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

            TextWriter writer = context.Response.Output;
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
            html.RenderControl(htmlWriter);
        }
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            fillgrid();
            string rpthtml = bindheader("excel");

            for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            {
                rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["date"].ToString() +
                          "</td><td>" + dsexcel.Tables[0].Rows[i]["empname"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["projectname"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["codename"].ToString() + "</td>"
                          + "<td>" + dsexcel.Tables[0].Rows[i]["description"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["Units"].ToString() + "</td>"
                          + "<td>" + dsexcel.Tables[0].Rows[i]["cost"].ToString() + "</td><td>" + dsexcel.Tables[0].Rows[i]["mu"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["amount"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["isbillable"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["reimbursable"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["memo"].ToString()
                          + "</td><td>" + dsexcel.Tables[0].Rows[i]["status"].ToString()
                          + "</td></tr>";
            }

            HtmlGenericControl divgen = new HtmlGenericControl();

            divgen.InnerHtml = rpthtml;

            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=\"HCLLPTimesheet.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 16
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            objts.nid       = "";
            objts.action    = "selectdetail";
            objts.companyId = Session["companyid"].ToString();
            objts.from      = txtfrmdate.Value;
            objts.to        = txttodate.Value;
            objts.Status    = dropsearchscheduletype.Text;
            objts.remark    = "excel";
            ds = objts.schedule();

            string rpthtml = "";

            if (ds.Tables[0].Rows.Count > 0)
            {
                rpthtml = ds.Tables[0].Rows[0]["description"].ToString();
            }

            HtmlGenericControl divgen = new HtmlGenericControl();


            divgen.InnerHtml = rpthtml;
            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=\"ScheduleReport.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    dv.InnerHtml = divgen.InnerHtml.Replace("border=0", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// Export report to excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            if (multiview1.ActiveViewIndex == 0)
            {
                exportsummary();
            }
            else
            {
                fillexcelreport();
                ltrreport.Text = bindheader("excel");

                HtmlGenericControl divgen = new HtmlGenericControl();
                StringWriter       sw1    = new StringWriter();
                HtmlTextWriter     hw1    = new HtmlTextWriter(sw1);
                divdetailreport.RenderControl(hw1);
                divgen.InnerHtml = sw1.ToString();
                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=\"ServerLogReport.xls\"");
                // create a string writer
                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                    {
                        System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                        dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");

                        dv.RenderControl(htw);
                        response.Write(sw.ToString());
                        response.End();
                    }
                }

                rptinner1.DataSource = null;
                rptinner1.DataBind();

                rptconfig1.DataSource = null;
                rptconfig1.DataBind();

                replogreport1.DataSource = null;
                replogreport1.DataBind();
            }
        }
Exemplo n.º 18
0
 private void CustomExport()
 {
     this.EnableViewState = false;
     PopulateGrid();
     Response.Clear();
     Response.Buffer          = true;
     Response.ContentType     = "application/vnd.ms-excel";
     Response.Charset         = "";
     Response.ContentEncoding = System.Text.Encoding.Default;
     Response.AddHeader("Content-Disposition", "filename=ReporteInternoRedespachoExcel.xls");
     CreateTitle();
     System.IO.StringWriter       oStringWriter   = new System.IO.StringWriter();
     System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
     todo.RenderControl(oHtmlTextWriter);
     Response.Write(oStringWriter.ToString());
     Response.End();
 }
 /// <summary>
 /// Includes an html markup like <script type=text/css src=[YOUR_HREF]></script>
 /// </summary>
 /// <param name="htmlHelper"></param>
 /// <param name="path"></param>
 /// <param name="includeVersionBasedOnLastModifiedDate">adding the query param "v" = [yyyyMMddHHmmss] based on file last modified date</param>
 /// <returns></returns>
 public static IHtmlString IncludeJS(this HtmlHelper htmlHelper, string path, bool includeVersionBasedOnLastModifiedDate = true)
 {
     string physicalPath = htmlHelper.ViewContext.HttpContext.Server.MapPath(path);
     var fileInfo = new FileInfo(physicalPath);
     if (!fileInfo.Exists) return new RawHtmlString(String.Empty);
     var lastModifiedDate = fileInfo.LastWriteTime;
     var sb = new StringBuilder();
     using (var textWriter = new StringWriter(sb))
     {
         using (var htmlWriter = new HtmlTextWriter(textWriter))
         {
             var htmlScript = new HtmlGenericControl("script");
             htmlScript.Attributes["type"] = "text/javascript";
             htmlScript.Attributes["src"] = String.Format("{0}?v={1:yyyyMMddHHmmss}", VirtualPathUtility.ToAbsolute(path), lastModifiedDate);
             htmlScript.RenderControl(htmlWriter);
         }
     }
     return new RawHtmlString(sb.ToString());
 }
Exemplo n.º 20
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            dsexcel = (DataSet)Session["TaskTable"];
            string rpthtml = bindheader("excel");

            for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            {
                rpthtml += "<tr>";
                for (int j = 0; j < dsexcel.Tables[0].Columns.Count; j++)
                {
                    rpthtml += "<td>" + dsexcel.Tables[0].Rows[i][j].ToString() + "</td>";
                }
            }

            HtmlGenericControl divgen = new HtmlGenericControl();


            divgen.InnerHtml = rpthtml;
            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=\"CumulativeReport.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                    //dv.InnerHtml = dv.InnerHtml.Replace("<tr><td colspan='6'><hr style='width:100%;' /></td>", "");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// Adds a new row to the Prevalue Editor, (with an optional description).
        /// </summary>
        /// <param name="writer">The HtmlTextWriter.</param>
        /// <param name="label">The label for the field.</param>
        /// <param name="description">The description for the field.</param>
        /// <param name="controls">The controls for the field.</param>
        public static void AddPrevalueRow(this HtmlTextWriter writer, string label, string description, params Control[] controls)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "row clearfix");
            writer.RenderBeginTag(HtmlTextWriterTag.Div); // start 'row'

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

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

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

            lbl.RenderControl(writer);

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

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

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

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

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

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

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

            writer.RenderEndTag(); // end 'row'
        }
Exemplo n.º 22
0
        /// <summary>
        /// Export report to excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            if (multiview1.ActiveViewIndex == 0)
            {
                exportsummary();
            }
            else
            {
                string rpthtml = bindheader("excel");
                rpthtml = rpthtml + @"<table width='100%' cellpadding='5' cellspacing='0' style='font-family: Calibri;   font-size: 12px; text-align: left;' border='0'>
<tr><td align='center'>Server Configuration Report</td> </tr>
<tr><td>&nbsp;</td></tr><tr><td>";
                HtmlGenericControl divgen = new HtmlGenericControl();
                StringWriter       sw1    = new StringWriter();
                HtmlTextWriter     hw1    = new HtmlTextWriter(sw1);
                DivExport.RenderControl(hw1);
                divgen.InnerHtml = rpthtml + sw1.ToString() + "</td></tr></table>";

                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=\"ServerConfigurationReport.xls\"");
                // create a string writer
                using (StringWriter sw = new StringWriter())
                {
                    using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                    {
                        System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                        dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");
                        dv.InnerHtml = divgen.InnerHtml.Replace("border=\"0\"", "border='1'");

                        dv.RenderControl(htw);
                        response.Write(sw.ToString());
                        response.End();
                    }
                }
            }
        }
Exemplo n.º 23
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            // bindheader("excel");
            HtmlGenericControl divgen = new HtmlGenericControl();


            StringWriter sw1 = new StringWriter();

            HtmlTextWriter hw1 = new HtmlTextWriter(sw1);

            divreport.RenderControl(hw1);


            divgen.InnerHtml = sw1.ToString();
            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=\"HCLLP-PerformanceReport.xls\"");

            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 24
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            //fillgrid();
            //string rpthtml = bindheader("excel");
            //for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
            //{
            //    rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["date"].ToString() + ' ' + dsexcel.Tables[0].Rows[i]["Time"].ToString() +
            //        "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["empname"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["clientname"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["projectcode"].ToString() + "</td>"
            //        + "<td>" + dsexcel.Tables[0].Rows[i]["scheduletype"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["status"].ToString() + "</td>"
            //        + "<td>" + dsexcel.Tables[0].Rows[i]["remark"].ToString() + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["username"].ToString() + "</td></tr>";
            //}

            HtmlGenericControl divgen = new HtmlGenericControl();

            // divgen.InnerHtml = rpthtml;
            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=\"ClientScheduleReport.xls\"");
            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divreport.InnerHtml.Replace("border='0'", "border='1'");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }
Exemplo n.º 25
0
        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl section = new HtmlGenericControl("div");
            section.Attributes["class"] = "archiveLinksContainerStyle";
            this.Controls.Add(section);

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    ul.Controls.Add(li);
                }

                using (var sw = new StringWriter())
                {
                    ul.RenderControl(new HtmlTextWriter(sw));
                    return sw.ToString();
                }
            }
        }
Exemplo n.º 27
0
        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl iFrame = new HtmlGenericControl("iframe");
            iFrame.Attributes.Add("name", this.JsonId + "_iframe");
            HtmlGenericControl hidden = new HtmlGenericControl("input");
            hidden.Attributes.Add("type", "hidden");
            hidden.Attributes.Add("name", "JsonId");
            hidden.Attributes.Add("value", this.JsonId);

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

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

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

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

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

            if (this.RenderScripts)
                this.RenderConglomerateScript(writer);
        }
Exemplo n.º 28
0
        protected void createPrevalueTable(HtmlTextWriter writer, Options renderingOptions)
        {
            HtmlGenericControl table = new HtmlGenericControl("table");

            HtmlGenericControl tbody = new HtmlGenericControl("tbody");
            table.Controls.Add(tbody);

            HtmlGenericControl tr = new HtmlGenericControl("tr");
            tbody.Controls.Add(tr);

            HtmlGenericControl th = new HtmlGenericControl("th");
            tr.Controls.Add(th);
            th.InnerHtml = "Media Tree Nodes IDs (CSV)";

            HtmlGenericControl td = new HtmlGenericControl("td");
            tr.Controls.Add(td);
            TextBox textbox = new TextBox();
            textbox.Attributes["class"] = "mediaNodes";
            td.Controls.Add(textbox);

            textbox.Text = renderingOptions.mediaIDs;

            table.RenderControl(writer);
        }
Exemplo n.º 29
0
 protected string GetListHtml()
 {
     HtmlGenericControl ul = new HtmlGenericControl("ul");
     DataSet ds = DbProvider.Instance().GetAggregateStats(BlogGroup);
     DataTable dt = ds.Tables[0];
     if (dt != null && dt.Rows.Count > 0)
     {
         int r = 0;
         int LastGroupId = (Int32)dt.Rows[0]["BlogGroupId"];
         if (ShowGroups)
         {
             while (r < dt.Rows.Count)
             {
                 HtmlGenericControl groupLi = new HtmlGenericControl("li");
                 HtmlGenericControl h3 = new HtmlGenericControl("h3");
                 h3.InnerHtml = dt.Rows[r]["BlogGroupTitle"].ToString();
                 groupLi.Controls.Add(h3);
                 ul.Controls.Add(groupLi);
                 HtmlGenericControl groupUl = new HtmlGenericControl("ul");
                 while (r < dt.Rows.Count && LastGroupId == (Int32)dt.Rows[r]["BlogGroupId"])
                 {
                     HtmlGenericControl bloggerLi = new HtmlGenericControl("li");
                     HtmlAnchor anc = new HtmlAnchor();
                     anc.InnerHtml = dt.Rows[r]["Author"].ToString();
                     anc.HRef = GetFullUrl(dt.Rows[r]["Host"].ToString(), dt.Rows[r]["Application"].ToString());
                     bloggerLi.Controls.Add(anc);
                     HtmlGenericControl sm = new HtmlGenericControl("small");
                     sm.InnerHtml = string.Format("<br />{0}, {1} {2}", dt.Rows[r]["PostCount"], ((DateTime)dt.Rows[r]["LastUpdated"]).ToShortDateString(), ((DateTime)dt.Rows[r]["LastUpdated"]).ToShortTimeString());
                     bloggerLi.Controls.Add(sm);
                     groupUl.Controls.Add(bloggerLi);
                     r++;
                 }
                 if (r < dt.Rows.Count)
                     LastGroupId = (Int32)dt.Rows[r]["BlogGroupId"];
                 groupLi.Controls.Add(groupUl);
             }
         }
         else
         {
                 while (r < dt.Rows.Count)
                 {
                     HtmlGenericControl bloggerLi = new HtmlGenericControl("li");
                     HtmlAnchor anc = new HtmlAnchor();
                     anc.InnerHtml = dt.Rows[r]["Author"].ToString();
                     anc.HRef = GetFullUrl(dt.Rows[r]["Host"].ToString(), dt.Rows[r]["Application"].ToString());
                     bloggerLi.Controls.Add(anc);
                     HtmlGenericControl sm = new HtmlGenericControl("small");
                     sm.InnerHtml = string.Format("<br />{0}, {1} {2}", dt.Rows[r]["PostCount"], ((DateTime)dt.Rows[r]["LastUpdated"]).ToShortDateString(), ((DateTime)dt.Rows[r]["LastUpdated"]).ToShortTimeString());
                     bloggerLi.Controls.Add(sm);
                     ul.Controls.Add(bloggerLi);
                     r++;
                 }
         }
     }
     System.IO.StringWriter sw = new System.IO.StringWriter();
     ul.RenderControl(new HtmlTextWriter(sw));
     return sw.ToString();
 }
Exemplo n.º 30
0
        private string RenderMonths(SortedDictionary<DateTime, int> Months)
        {
            if (Months.Keys.Count == 0)
                return string.Empty;

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

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

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

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

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

                HtmlGenericControl li = new HtmlGenericControl("li");

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

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

            StringWriter sw = new StringWriter();
            ul.RenderControl(new HtmlTextWriter(sw));
            return sw.ToString();
        }
Exemplo n.º 31
0
        protected override void RenderContents(HtmlTextWriter writer)
        {
            if (this.DesignMode)
            {
                return;
            }

            if (this.ProcessCertificateDownloadRequest())
            {
                return;
            }

            string divId = string.Format(CultureInfo.InvariantCulture, "{0}_div", this.ID);

            HtmlGenericControl container = new HtmlGenericControl("div") { ID = divId };

            ClientScriptManager clientScriptManager = this.Page.ClientScript;
            HtmlImage controlImage = new HtmlImage
            {
                ID = string.Format(CultureInfo.CurrentUICulture, "STVC{0}", Guid.NewGuid()),
                Src = clientScriptManager.GetWebResourceUrl(typeof(SecurityTokenVisualizerControl), "Microsoft.Samples.DPE.Identity.Controls.Content.images.icon.png"),
                Alt = Resources.SecurityTokenVisualizer,
            };

            controlImage.Attributes["title"] = Resources.SecurityTokenVisualizer;

            HtmlControl tokenVisualizerHeader = this.CreateCollapsableHeader(controlImage, container, false /* Expanded as Default */);

            if (this.Font == null || string.IsNullOrEmpty(this.Font.Name))
            {
                container.Style["font-family"] = "Arial, Consolas, Segoe UI";
                tokenVisualizerHeader.Style["font-family"] = "Arial, Consolas, Segoe UI";
            }
            if (this.Font == null || this.Font.Size.IsEmpty)
            {
                container.Style["font-size"] = "small";
                tokenVisualizerHeader.Style["font-size"] = "small";
            }

            var containerRounded = this.AddContainerRounded(container);

            if (Thread.CurrentPrincipal.Identity.IsAuthenticated && Thread.CurrentPrincipal.Identity is IClaimsIdentity)
            {
                AddClaimsTable(containerRounded);
                containerRounded.Controls.Add(new HtmlGenericControl() { InnerHtml = "&nbsp;" });
                this.AddSamlTokenTable(containerRounded);
            }
            else
            {
                AddNotAuthenticatedUserTable(containerRounded);
            }

            tokenVisualizerHeader.RenderControl(writer);

            container.RenderControl(writer);

            base.RenderContents(writer);
        }
Exemplo n.º 32
0
        public override string XGetDesignTimeHtml(DesignerRegionCollection regions)
        {
            StringWriter writer = new StringWriter(CultureInfo.CurrentCulture);
            HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
            this.designerRegions = regions;

            this.layout.Height = Unit.Percentage(100);

            foreach (BorderLayoutRegion region in this.layout.Regions)
            {
                foreach (PanelBase item in region.Items)
                {
                    this.layout.Controls.Add(item);
                }
            }

            //if (this.layout.Height.Type != UnitType.Pixel)
            //{
            //    PropertyDescriptor descriptor = TypeDescriptor.GetProperties(this.layout)["Height"];
            //    descriptor.SetValue(this.layout, Unit.Pixel((int) this.layout.Height.Value));
            //    this.layout.Height = Unit.Percentage(100);
            //    //this.layout.Height = Unit.Pixel((int) this.layout.Height.Value);
            //    Tag.SetDirty(true);
            //}

            HtmlGenericControl mainDiv = new HtmlGenericControl("div");
            mainDiv.Style["width"] = Unit.Percentage(100).ToString();
            mainDiv.Style["height"] = Unit.Percentage(100).ToString();
            mainDiv.Style["overflow"] = "hidden";

            Table table = new Table();
            table.CellPadding = 0;
            table.CellSpacing = 0;
            table.BorderWidth = 0;
            table.Width = Unit.Percentage(100);
            table.Height = Unit.Percentage(100);

            table.CssClass = "ext-ie ext-ie7 ext-border-box x-border-layout-ct";

            Unit height;
            TableRow row;
            TableCell cell;
            bool northExists = this.layout.North.Items.Count > 0;
            bool southExists = this.layout.South.Items.Count > 0;
            bool westExists = this.layout.West.Items.Count > 0;
            bool eastExists = this.layout.East.Items.Count > 0;
            string margins;
            Margins marginsObj;

            if (northExists || this.SchemeMode)
            {
                row = new TableRow();
                cell = new TableCell();
                cell.ColumnSpan = 3;
                cell.VerticalAlign = VerticalAlign.Top;
                cell.Width = Unit.Percentage(100);

                if (northExists && ((this.layout.North.Items[0] is PanelBase) && (this.layout.North.Items[0] as PanelBase).Collapsed) && this.layout.North.Collapsible && !this.SchemeMode)
                {
                    marginsObj = this.layout.North.CMargins;

                    if (marginsObj.IsDefault)
                    {
                        margins = "5px 5px 5px 5px";
                    }
                    else
                    {
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right + (this.layout.West.Split ? 5 : 0), marginsObj.Bottom, marginsObj.Left);
                    }

                    cell.Style["padding"] = margins;

                    cell.Controls.Add(this.BuildCollapsedRegion(this.layout.North));
                    row.Height = Unit.Pixel(32);
                }
                else
                {
                    if (northExists)
                    {
                        height = this.layout.North.Items[0] is BoxComponentBase ? ((BoxComponentBase)this.layout.North.Items[0]).Height : this.layout.North.Items[0].Height;
                    }
                    else
                    {
                        height = new Unit((int)(table.Height.Value * 0.3), table.Height.Type);
                    }
                    
                    if (!this.SchemeMode)
                    {
                        row.Height = height;
                        marginsObj = this.layout.North.Margins;
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right, marginsObj.Bottom + (this.layout.North.Split ? 5 : 0), marginsObj.Left);
                        cell.Style["padding"] = margins;
                    }


                    cell.Controls.Add(this.BuildRegion(this.layout.North, Unit.Percentage(100), height));
                }

                row.Cells.Add(cell);
                table.Rows.Add(row);
            }

            row = new TableRow();
            height = Unit.Percentage(100);
            row.VerticalAlign = VerticalAlign.Top;

            //Table centerTable = new Table();
            //centerTable.CellPadding = 0;
            //centerTable.CellSpacing = 0;
            //centerTable.BorderWidth = 0;
            //centerTable.Width = Unit.Percentage(100);
            //centerTable.Height = Unit.Percentage(100);

            //TableRow centerRow = new TableRow();

            int centerColSpan = (this.layout.West.Items.Count == 0 && !this.SchemeMode ? 1 : 0) +
                                (this.layout.East.Items.Count == 0 && !this.SchemeMode ? 1 : 0) + 1;

            if (westExists || this.SchemeMode)
            {
                cell = new TableCell();
                cell.Wrap = false;

                if (westExists && ((this.layout.West.Items[0] is PanelBase) && (this.layout.West.Items[0] as PanelBase).Collapsed) && this.layout.West.Collapsible && !this.SchemeMode)
                {
                    cell.Width = Unit.Pixel(25);
                    //cell.Width = Unit.Percentage(1);
                    marginsObj = this.layout.West.CMargins;

                    if (marginsObj.IsDefault)
                    {
                        margins = "0px 5px 2px 5px";
                    }
                    else
                    {
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right + (this.layout.West.Split ? 5 : 0), marginsObj.Bottom + 2, marginsObj.Left);
                    }

                    cell.Style["padding"] = margins;

                    cell.Controls.Add(this.BuildCollapsedRegion(this.layout.West));
                }
                else
                {
                    if (westExists)
                    {
                        cell.Width = this.layout.West.Items[0] is BoxComponentBase ? ((BoxComponentBase)this.layout.West.Items[0]).Width : this.layout.West.Items[0].Width;
                    }
                    else
                    {
                        cell.Width = Unit.Pixel((int)(table.Width.Value * 0.2));
                    }
                    
                    if (!this.SchemeMode)
                    {


                        marginsObj = this.layout.West.Margins;
                        int addBottomMargins = 27 + (this.layout.West.Items[0] is TabPanel ? 2 : 0);
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right + (this.layout.West.Split ? 5 : 0), marginsObj.Bottom + addBottomMargins, marginsObj.Left);
                        cell.Style["padding"] = margins;
                    }

                    cell.Controls.Add(this.BuildRegion(this.layout.West, cell.Width, height));
                }

                row.Cells.Add(cell);
            }

            cell = new TableCell();

            if (centerColSpan > 1)
            {
                cell.ColumnSpan = centerColSpan;
            }

            cell.Width = Unit.Percentage(99);

            cell.Wrap = false;

            if (!this.SchemeMode)
            {
                marginsObj = this.layout.Center.Margins;
                int addBottomMargins = 27 + (this.layout.Center.Items[0] is TabPanel ? 2 : 0);
                margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right, marginsObj.Bottom + addBottomMargins, marginsObj.Left);
                cell.Style["padding"] = margins;
            }
            cell.Controls.Add(this.BuildRegion(this.layout.Center, Unit.Percentage(100), height));
            row.Cells.Add(cell);

            if (eastExists || this.SchemeMode)
            {
                cell = new TableCell();
                cell.Wrap = false;

                if (eastExists && ((this.layout.East.Items[0] is PanelBase) && (this.layout.East.Items[0] as PanelBase).Collapsed) && this.layout.East.Collapsible && !this.SchemeMode)
                {
                    cell.Width = Unit.Pixel(25);
                    //cell.Width = Unit.Percentage(1);
                    marginsObj = this.layout.East.CMargins;

                    if (marginsObj.IsDefault)
                    {
                        margins = "0px 5px 2px 5px";
                    }
                    else
                    {
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right + (this.layout.West.Split ? 5 : 0), marginsObj.Bottom + 2, marginsObj.Left);
                    }

                    cell.Style["padding"] = margins;

                    cell.Controls.Add(this.BuildCollapsedRegion(this.layout.East));
                }
                else
                {
                    if (eastExists)
                    {
                        cell.Width = this.layout.East.Items[0] is BoxComponentBase ? ((BoxComponentBase)this.layout.East.Items[0]).Width : this.layout.East.Items[0].Width;
                    }
                    else
                    {
                        cell.Width = Unit.Pixel((int)(table.Width.Value * 0.2));
                    }
                    
                    if (!this.SchemeMode)
                    {

                        marginsObj = this.layout.East.Margins;
                        int addBottomMargins = 27 + (this.layout.East.Items[0] is TabPanel ? 2 : 0);
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right, marginsObj.Bottom + addBottomMargins, marginsObj.Left + (this.layout.East.Split ? 5 : 0));
                        cell.Style["padding"] = margins;
                    }

                    cell.Controls.Add(this.BuildRegion(this.layout.East, cell.Width, height));
                }

                row.Cells.Add(cell);
            }
            //centerTable.Rows.Add(centerRow);

            //cell = new TableCell();
            //cell.Wrap = false;
            //cell.Controls.Add(centerTable);

            //row.Cells.Add(cell);

            table.Rows.Add(row);

            if (southExists || this.SchemeMode)
            {
                row = new TableRow();
                cell = new TableCell();
                cell.ColumnSpan = 3;
                cell.VerticalAlign = VerticalAlign.Top;
                cell.Width = Unit.Percentage(100);

                if (southExists && ((this.layout.South.Items[0] is PanelBase) && (this.layout.South.Items[0] as PanelBase).Collapsed) && this.layout.South.Collapsible && !this.SchemeMode)
                {
                    marginsObj = this.layout.South.CMargins;

                    if (marginsObj.IsDefault)
                    {
                        margins = "5px 5px 5px 5px";
                    }
                    else
                    {
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top, marginsObj.Right + (this.layout.West.Split ? 5 : 0), marginsObj.Bottom, marginsObj.Left);
                    }

                    cell.Style["padding"] = margins;
                    cell.Controls.Add(this.BuildCollapsedRegion(this.layout.South));
                    row.Height = Unit.Pixel(32);
                }
                else
                {
                    if (southExists)
                    {
                        height = this.layout.South.Items[0] is BoxComponentBase ? ((BoxComponentBase)this.layout.South.Items[0]).Height : this.layout.South.Items[0].Height;
                    }
                    else
                    {
                        height = new Unit((int)(table.Height.Value * 0.3), table.Height.Type);
                    }
                    

                    if (!this.SchemeMode)
                    {
                        cell.Height = height;
                        marginsObj = this.layout.South.Margins;
                        margins = "{0}px {1}px {2}px {3}px".FormatWith(marginsObj.Top + (this.layout.South.Split ? 5 : 0), marginsObj.Right, marginsObj.Bottom, marginsObj.Left);
                        cell.Style["padding"] = margins;
                    }

                    cell.Controls.Add(this.BuildRegion(this.layout.South, Unit.Percentage(100), height));
                }

                row.Cells.Add(cell);
                table.Rows.Add(row);
            }

            mainDiv.Controls.Add(table);
            mainDiv.Controls.Add(new LiteralControl(this.GetIconStyleBlock()));

            mainDiv.RenderControl(htmlWriter);

            //this.Invalidate();

            //StringBuilder sb = new StringBuilder(256);

            //base.Render(new HtmlTextWriter(new StringWriter(sb)));
            //writer.Write(
            //    sb.ToString().Trim().Replace(Environment.NewLine, "").Replace("\n", "").Replace(
            //        "\t", "").Replace("id=\"" + this.ClientID + "\"", "id=\"" + this.ContainerID + "\""));

            return writer.ToString();
        }
Exemplo n.º 33
0
        public static string CreateVendorHistory(IConfigurationService configurationService, VendorOrderHistory vendorOrderHistory)
        {
            using (var stringWriter = new StringWriter())
            {
                using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                {
                    var html = new HtmlGenericControl("html");

                    var head = new HtmlGenericControl("head");
                    LiteralControl ltr = new LiteralControl
                    {
                        Text = "<style type=\"text/css\" rel=\"stylesheet\">" +
                               @"
                    table {
                        border-collapse: collapse;
                        width: 100%;
                        border: 1px solid #cacaca;
                    }

                    th, td
                    {
                        text-align: left;
                        padding: 10px;
                        border:1px solid black;
                    }

                    span {
                        font-size: 14px;
                        display: block;
                        padding: 5px;
                    }

                    th
                    {
                        background-color: #c6d2ff;
                    }
                    tr:nth-child(even)
                    {
                        background-color: #f2f2f2;
                    }
                    footer { margin-top: 40px; }
                    footer p.leading { font-size: 24px; font-weight: bold; }

                    </style>
                    "
                    };

                    head.Controls.Add(ltr);

                    var body = new HtmlGenericControl("body");

                    var heading = new HtmlGenericControl("h1")
                    {
                        InnerText = $"Order {vendorOrderHistory.OrderDate}"
                    };

                    body.Controls.Add(heading);

                    //Generate container div control
                    HtmlGenericControl divControl = new HtmlGenericControl("div");
                    body.Controls.Add(divControl);

                    HtmlGenericControl tableControl = new HtmlGenericControl("table");

                    HtmlGenericControl tableHeadControl = new HtmlGenericControl("thead");
                    HtmlGenericControl tableHeadTitleUser = new HtmlGenericControl("th") { InnerText = "User" };
                    HtmlGenericControl tableHeadTitleOrder = new HtmlGenericControl("th") { InnerText = "Order" };
                    HtmlGenericControl tableHeadTitlePrice = new HtmlGenericControl("th") { InnerText = "Price" };

                    tableHeadControl.Controls.Add(tableHeadTitleUser);
                    tableHeadControl.Controls.Add(tableHeadTitleOrder);
                    tableHeadControl.Controls.Add(tableHeadTitlePrice);
                    tableControl.Controls.Add(tableHeadControl);

                    var totalPrice = 0M;
                    foreach (var entry in vendorOrderHistory.Entries)
                    {
                        var tableRow = new HtmlGenericControl("tr");
                        var tableColumnUsername = new HtmlGenericControl("td") { InnerText = entry.FullName };

                        var entryText = entry.Name;
                        if (!string.IsNullOrEmpty(entry.FreeText))
                        {
                            entryText = $"{entry.Name} ({entry.FreeText})";
                        }

                        var tableColumnOrder = new HtmlGenericControl("td") { InnerText = entryText };

                        if (entry.Rules != null)
                        {
                            foreach (var rule in entry.Rules)
                            {
                                var tableColumnOrderRule = new HtmlGenericControl("p") { InnerText = rule.Description };
                                tableColumnOrder.Controls.Add(tableColumnOrderRule);
                            }
                        }

                        var tableColumnPrice = new HtmlGenericControl("td")
                        {
                            InnerText = entry.FinalPrice.ToString(CultureInfo.InvariantCulture)
                        };

                        tableRow.Controls.Add(tableColumnUsername);
                        tableRow.Controls.Add(tableColumnOrder);
                        tableRow.Controls.Add(tableColumnPrice);
                        tableControl.Controls.Add(tableRow);

                        totalPrice += entry.FinalPrice;
                    }

                    var totalRow = new HtmlGenericControl("tr");
                    var emptyColumn1 = new HtmlGenericControl("td") { InnerText = "" };
                    var emptyColumn2 = new HtmlGenericControl("td") { InnerText = "" };
                    totalRow.Controls.Add(emptyColumn1);
                    totalRow.Controls.Add(emptyColumn2);
                    var totalColumn = new HtmlGenericControl("td") { InnerText = $"Total: {totalPrice}" };
                    totalRow.Controls.Add(totalColumn);
                    tableControl.Controls.Add(totalRow);

                    divControl.Controls.Add(tableControl);

                    body.Controls.Add(CreateFooter(configurationService));
                    html.Controls.Add(head);
                    html.Controls.Add(body);
                    html.RenderControl(htmlWriter);
                }
                return stringWriter.ToString();
            }
        }
        public HttpResponseMessage GetMarkerEditForm(string filename, bool richtext = false)
        {
            string result = Common.GetResourceText(filename);
            StringBuilder sbFiles = new StringBuilder();

            string folderPath = "/Umbraco/Images/MapPins/";
            if (Directory.Exists(HttpContext.Current.Server.MapPath(folderPath)))
            {
                foreach (string file in Directory.GetFiles(HttpContext.Current.Server.MapPath(folderPath)))
                {
                    using (StringWriter stringWriter = new StringWriter())
                    {
                        using (HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter))
                        {
                            HtmlGenericControl optionHtml = new HtmlGenericControl("option");
                            optionHtml.Attributes.Add("value", string.Concat(folderPath, Path.GetFileName(file)));
                            optionHtml.InnerText = Path.GetFileName(file);
                            optionHtml.RenderControl(htmlWriter);
                            sbFiles.Append(stringWriter.ToString());
                            optionHtml.Dispose();
                        }
                    }
                }
            }

            return new HttpResponseMessage()
            {
                Content = new StringContent(string.Format(result, sbFiles.ToString(), richtext ? "richtext-fix" : string.Empty), System.Text.Encoding.UTF8, "application/html")
            };
        }
Exemplo n.º 35
0
		private void RenderTableFooter(HtmlTextWriter writer)
		{
			if(_footerTemplate == null)
				return;

			var container = new HtmlGenericControl("tfoot");
			_footerTemplate.InstantiateIn(container);
			container.RenderControl(writer);
		}
Exemplo n.º 36
0
        private string LoadInformation(DataTable table)
        {
            DataGrid grid = new DataGrid();
            BoundColumn col;

            col = new BoundColumn();
            col.DataField = "Name";
            col.HeaderText = "Name";
            col.ItemStyle.CssClass = "name";
            col.ItemStyle.Width = new Unit(400);
            grid.Columns.Add(col);

            col = new BoundColumn();
            col.DataField = "Value";
            col.HeaderText = "Value";
            col.ItemStyle.CssClass = "value";
            col.ItemStyle.Width = new Unit(624);
            grid.Columns.Add(col);

            grid.AutoGenerateColumns = false;
            grid.HeaderStyle.CssClass = "header";
            grid.DataSource = new DataView(table);
            grid.DataBind();

            foreach (DataGridItem item in grid.Items)
            {
                if (item.Cells.Count == 2)
                {
                    TableCell cell = item.Cells[1];
                    //  change true/false style
                    switch (cell.Text.ToLower())
                    {
                        case "true":
                            cell.CssClass = "value_true";
                            break;

                        case "false":
                            cell.CssClass = "value_false";
                            break;
                    }

                    ////  wrap <pre> for text contain newline.
                    //if (cell.Text.IndexOf(Environment.NewLine) >= 0)
                    //{
                    //    cell.Wrap = true;
                    //    cell.Text = string.Format("{0}", cell.Text);
                    //}
                }
            }

            HtmlGenericControl title = new HtmlGenericControl("h1");
            title.InnerText = _context.Server.HtmlEncode(table.TableName);
            title.Attributes.Add("class", "title");

            HtmlGenericControl div = new HtmlGenericControl("div");
            div.Attributes.Add("class", "section");
            div.Controls.Add(new HtmlGenericControl("p"));
            div.Controls.Add(title);
            div.Controls.Add(grid);
            div.Controls.Add(new HtmlGenericControl("p"));

            StringBuilder generatedHtml = new StringBuilder();
            HtmlTextWriter htw = new HtmlTextWriter(new StringWriter(generatedHtml));
            div.RenderControl(htw);
            string output = generatedHtml.ToString();
            return output;
            //divCenter.Controls.Add(div);
        }
Exemplo n.º 37
0
		private void RenderTableHeader(HtmlTextWriter writer)
		{
			if(_headerTemplate != null)
			{
				var container = new HtmlGenericControl("thead");
				_headerTemplate.InstantiateIn(container);
				container.RenderControl(writer);
				return;
			}

			writer.RenderBeginTag(HtmlTextWriterTag.Thead);

			//开始生成表头行(<tr>
			writer.RenderBeginTag(HtmlTextWriterTag.Tr);

			//生成选择列
			this.GenerateSelection(writer, true, null);

			//表头列(开始)
			foreach(GridColumnBase column in _columns)
			{
				string style = string.Empty;

				if(!string.IsNullOrWhiteSpace(column.Name))
					writer.AddAttribute(HtmlTextWriterAttribute.Name, column.Name);
				if(!string.IsNullOrWhiteSpace(column.CssClass))
					writer.AddAttribute(HtmlTextWriterAttribute.Class, column.CssClass);

				writer.AddAttribute(HtmlTextWriterAttribute.Align, column.TitleAlignment.ToString().ToLowerInvariant());

				if(column.Visible)
				{
					if(column.Width.Value != 0)
						style = "width:" + Utility.GetWidth(column.Width, _columns.GetTotalWeight());
				}
				else
				{
					style = "display:none;";
				}

				if(!string.IsNullOrEmpty(style))
					writer.AddAttribute(HtmlTextWriterAttribute.Style, style);

				writer.RenderBeginTag(HtmlTextWriterTag.Th);

				if(string.IsNullOrWhiteSpace(column.Title))
					writer.Write("&nbsp;");
				else
					writer.Write(column.Title);

				writer.RenderEndTag();
			}//表头列(结束)

			//结束生成表头行(</tr>
			writer.RenderEndTag();

			//结束生成表头部分
			writer.RenderEndTag();
		}
Exemplo n.º 38
0
        protected override void RenderChildren(HtmlTextWriter writer)
        {
            if (this.Controls.Count == 0) // nothing to render, use default
            {
                base.RenderChildren(writer);
                return;
            }

            // this method contains some specific code to allow showing a scrollbar within the table
            // the trick is to render the table header row 2x.
            // the first div will render only the header
            // the second table will display only the rows within a sereprate scrollable div.
            // some additional javascript is needed to make sure the colums widths and header heights align.

            // select the header row in the grid
            WebControl ctrl    = (WebControl)this.Controls[0]; // the table
            Control    ctrlrow = ctrl.Controls[0];             // the table->row[0]

            // tricky bit here
            System.Web.UI.HtmlControls.HtmlGenericControl divhead = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            divhead.Attributes["class"] = "GridViewHeaderContainer"; //style is hardcoded, required by jquery
            divhead.Style.Add("overflow", "hidden");
            if (this.Width != Unit.Empty)
            {
                divhead.Style.Add("width", this.Width.ToString()); // assign new width, overrule stylesheet.
            }
            Table tablehead = new Table();

            tablehead.ApplyStyle(this.HeaderStyle);
            tablehead.Style.Add("width", "100%");
            tablehead.ID = ctrl.UniqueID + "$Header";
            tablehead.Controls.Add(ctrlrow); // this will automatically bind the row to the new parent control (and remove itself from previous container)
            divhead.Controls.Add(tablehead);
            divhead.RenderControl(writer);   // will render the whole table, this will make sure the header will align. only header will be visible

            System.Web.UI.HtmlControls.HtmlGenericControl divbody = new System.Web.UI.HtmlControls.HtmlGenericControl("DIV");
            divbody.Attributes["class"] = "GridViewBodyContainer"; //style is hardcoded for jquery

            if (this.Width != Unit.Empty)
            {
                divbody.Style.Add("width", this.Width.ToString()); // assign new width, overrule stylesheet.
            }
            if (this.Height != Unit.Empty)
            {
                divbody.Style.Add("height", this.Height.ToString()); // assign new height, overrule stylesheet.
            }
            divbody.Style.Add("overflow", "hidden");
            divbody.Style.Add("overflow-y", "auto");

            ctrl.Style.Add("width", "100%");

            ctrl.Controls.AddAt(0, ctrlrow); // this will automatically bind the row to the parent control (and remove itself from previous container)
            divbody.Controls.AddAt(0, ctrl); // bind the table to the body div(and remove itself from previous container)
            divbody.RenderControl(writer);   // will render the whole table again except header row, only the body part will be visible, parent div will be scrollable

            this.Controls.AddAt(0, ctrl);    // restore to previous container, this way the control will not break

            // render the rest of the controls (in this case only the footer)
            for (int i = 1; i < this.Controls.Count; i++)
            {
                ctrl = (WebControl)this.Controls[i];
                ctrl.RenderControl(writer);
            }
        }
Exemplo n.º 39
0
        private string RenderMonths()
        {
            if (_Months.Keys.Count == 0)
                return "<p>" + Resources.labels.none + "</p>";

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

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

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

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

                    if (date.Year == DateTime.Now.Year)
                        list.Attributes.Add("class", "open");

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

                HtmlGenericControl li = new HtmlGenericControl("li");

                HtmlAnchor anc = new HtmlAnchor();
                anc.HRef = Utils.RelativeWebRoot + date.Year + "/" + date.ToString("MM") + "/default" + BlogSettings.Instance.FileExtension;
                anc.InnerHtml = DateTime.Parse(date.Year + "-" + date.Month + "-01").ToString("MMMM") + " (" + _Months[date] + ")";

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

            System.IO.StringWriter sw = new System.IO.StringWriter();
            ul.RenderControl(new HtmlTextWriter(sw));
            return sw.ToString();
        }
Exemplo n.º 40
0
        public override string XGetDesignTimeHtml(DesignerRegionCollection regions)
        {
            if (regions == null)
            {
                base.GetDesignTimeHtml(regions);
            }

            this.designerRegions = regions;

            HtmlGenericControl tabPanel = new HtmlGenericControl("div");
            tabPanel.Attributes["class"] = "{0}{1}".FormatWith(this.tabPanelControl.BaseCls,!this.tabPanelControl.Border ? " x-tab-panel-noborder" : "");
            tabPanel.Style["width"] = this.tabPanelControl.Width == Unit.Empty ? "auto" : this.tabPanelControl.Width.ToString();

            if (this.tabPanelControl.TabPosition == TabPosition.Top && this.tabPanelControl.Items.Count>0)
            {
                tabPanel.Controls.Add(BuildTabs(TabPosition.Top));
            }

            tabPanel.Controls.Add(this.BuildBody());
            
            StringWriter sr = new StringWriter(CultureInfo.CurrentCulture);
            HtmlTextWriter hw = new HtmlTextWriter(sr);
            tabPanel.RenderControl(hw);

            return sr.ToString();
        }
Exemplo n.º 41
0
        protected void renderGrid(HtmlTextWriter writer, Widget_Builder_Options renderingOptions)
        {
            HtmlGenericControl gridWrapper=new HtmlGenericControl();
            gridWrapper.TagName = "div";
            gridWrapper.Attributes["class"]="gridWrapperDiv";

            HtmlTable gridTable;

            foreach (WidgetElement element in renderingOptions.elements)
            {
                gridTable = new HtmlTable();
                gridTable.Attributes["class"] = "widgetGridTable";
                gridTable.Attributes["type"] = element.type;
                gridWrapper.Controls.Add(gridTable);

                //call each method dynamically based on the element type
                MethodInfo elementMethod = this.GetType().GetMethod(element.type);
                elementMethod.Invoke(this, new object[] { element, gridTable });
            }
            gridWrapper.RenderControl(writer);
        }
Exemplo n.º 42
0
        /// <summary>
        /// Writes the HTML Body element.
        /// </summary>
        protected virtual void RenderHtmlBody()
        {
            // Create the body tag and set it up so that Render calls
            // will have it available
            _body = new HtmlGenericControl("body");

            if (_showHeader)
                RenderPageHeader();

            RenderContents();

            if (_showFooter)
                RenderPageFooter();

            Page.Controls.Add(_body);
            _body.RenderControl(_writer);
            _writer.WriteLine();
        }
Exemplo n.º 43
0
        private string RenderComments()
        {
            if (_Comments.Count == 0)
            {
                return "<p>" + Resources.labels.none + "</p>";
            }

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

            foreach (Comment comment in _Comments)
            {
                if (comment.IsApproved)
                {
                    HtmlGenericControl li = new HtmlGenericControl("li");

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

                    // The comment count on the post
                    LiteralControl count = new LiteralControl(" (" + ((Post)comment.Parent).ApprovedComments.Count + ")<br />");
                    li.Controls.Add(count);

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

                        LiteralControl wrote = new LiteralControl(" " + Resources.labels.wrote + ": ");
                        li.Controls.Add(wrote);
                    }
                    else
                    {
                        LiteralControl author = new LiteralControl(comment.Author + " " + Resources.labels.wrote + ": ");
                        li.Controls.Add(author);
                    }

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

              commentBody = commentBody.Substring(0, bodyLength);
              if (commentBody.Length > 0)
              {
            if (commentBody[commentBody.Length - 1] == '&')
            {
              commentBody = commentBody.Substring(0, commentBody.Length - 1);
            }
              }
                    commentBody += comment.Content.Length <= 50 ? " " : "… ";
                    LiteralControl body = new LiteralControl(commentBody);
                    li.Controls.Add(body);

                    // The comment link
                    HtmlAnchor link = new HtmlAnchor();
                    link.HRef = comment.Parent.RelativeLink + "#id_" + comment.Id;
                    link.InnerHtml = "[" + Resources.labels.more + "]";
                    link.Attributes.Add("class", "moreLink");
                    li.Controls.Add(link);

                    ul.Controls.Add(li);
                }
            }

            StringWriter sw = new StringWriter();
            ul.RenderControl(new HtmlTextWriter(sw));
            return sw.ToString();
        }
Exemplo n.º 44
0
        protected override void Render(HtmlTextWriter writer)
        {
            HtmlGenericControl section = new HtmlGenericControl("div");
            section.Attributes["class"] = "navigatorLinksContainerStyle";
            this.Controls.Add(section);

            string controlType = "table";
            string controlClass = "navigatorLinksTableStyle";
            string listItemClass = "navigatorLinksCellStyle";

            if (renderAsList)
            {
                controlType = "ul";
                controlClass = "navigatorLinksListStyle";
                listItemClass = "navigatorLinksListItemStyle";
            }

            HtmlGenericControl list = new HtmlGenericControl(controlType);
            list.Attributes.Add("class", controlClass);
            section.Controls.Add(list);

            //FIX: Why do we support 2 different schema's for the SideBarList content???

            try
            {
                string fullPath = Path.Combine(SiteConfig.GetContentPathFromCurrentContext(), fileName);
                if (File.Exists(fullPath))
                {
                    NavigatorXml nav;
                    using (Stream s = File.OpenRead(fullPath))
                    {
                        XmlSerializer ser = new XmlSerializer(typeof(NavigatorXml));
                        nav = (NavigatorXml)ser.Deserialize(s);
                    }
                    foreach (NavigatorItem navitem in nav.Items)
                    {
                        HyperLink catLink = new HyperLink();
                        catLink.CssClass = "navigatorLinksLinkStyle";
                        catLink.Text = navitem.Name;
                        catLink.NavigateUrl = navitem.Url;

                        if (renderAsList)
                        {
                            HtmlGenericControl cell = new HtmlGenericControl("li");
                            cell.Attributes.Add("class", listItemClass);
                            list.Controls.Add(cell);
                            cell.Controls.Add(catLink);
                        }
                        else
                        {
                            TableRow row = new TableRow();
                            TableCell cell = new TableCell();
                            cell.CssClass = listItemClass;
                            list.Controls.Add(row);
                            row.Cells.Add(cell);
                            cell.Controls.Add(catLink);
                        }
                    }
                }
                else
                {
                    NavigationRoot nav;

                    fullPath = Path.Combine(SiteConfig.GetConfigPathFromCurrentContext(), fileName);
                    if (File.Exists(fullPath))
                    {
                        using (Stream s = File.OpenRead(fullPath))
                        {
                            XmlSerializer ser = new XmlSerializer(typeof(NavigationRoot));
                            nav = (NavigationRoot)ser.Deserialize(s);
                        }
                        foreach (NavigationLink navitem in nav.Items)
                        {
                            HyperLink catLink = new HyperLink();
                            catLink.CssClass = "navigatorLinksLinkStyle";
                            catLink.Text = navitem.Name;
                            catLink.NavigateUrl = navitem.Url;

                            if (renderAsList)
                            {
                                HtmlGenericControl cell = new HtmlGenericControl("li");
                                cell.Attributes.Add("class", listItemClass);
                                list.Controls.Add(cell);
                                cell.Controls.Add(catLink);
                            }
                            else
                            {
                                TableRow row = new TableRow();
                                TableCell cell = new TableCell();
                                cell.CssClass = listItemClass;
                                list.Controls.Add(row);
                                row.Cells.Add(cell);
                                cell.Controls.Add(catLink);
                            }
                        }
                    }
                    else
                    {
                        section.Controls.Add(new LiteralControl("Add '" + fileName + "' to your SiteConfig directory<br />"));
                    }
                }
            }
            catch (Exception exc)
            {
                ErrorTrace.Trace(System.Diagnostics.TraceLevel.Error, exc);
                section.Controls.Add(new LiteralControl("There was an error processing '" + fileName + "'<br />"));
            }

            section.RenderControl( writer );
        }
Exemplo n.º 45
0
        /// <summary>
        /// Renders the comments.
        /// </summary>
        /// <param name="comments">The comments.</param>
        /// <returns>The rendered html.</returns>
        private static string RenderComments(ICollection<Comment> comments)
        {
            if (comments.Count == 0)
            {
                // HttpRuntime.Cache.Insert("widget_recentcomments", "<p>" + Resources.labels.none + "</p>");
                return string.Format("<p>{0}</p>", labels.none);
            }

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

            foreach (var comment in comments)
            {
                if (comment.IsApproved)
                {
                    var li = new HtmlGenericControl("li");

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

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

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

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

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

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

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

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

                    ul.Controls.Add(li);
                }
            }

            var sw = new StringWriter();
            ul.RenderControl(new HtmlTextWriter(sw));

            const string Ahref =
                "<a href=\"{0}syndication.axd?comments=true\">Comment RSS <img src=\"{0}pics/rssButton.png\" alt=\"\" /></a>";
            var rss = string.Format(Ahref, Utils.RelativeWebRoot);
            sw.Write(rss);
            return sw.ToString();

            // HttpRuntime.Cache.Insert("widget_recentcomments", sw.ToString());
        }
Exemplo n.º 46
0
        protected void btnexportcsv_Click(object sender, EventArgs e)
        {
            string rpthtml    = "";
            string reportname = "";

            if (hidcurrentmode.Value == "salaryslip")
            {
                fillsalaryslip();
                reportname = "HCLLPPaySlip";
                rpthtml    = bindheader("", "6");

                StringWriter   sw   = new StringWriter();
                Control        ctrl = divsalaryslip;
                HtmlTextWriter hw   = new HtmlTextWriter(sw);

                ctrl.RenderControl(hw);

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

                rpthtml = rpthtml + sw.ToString();
            }
            else if (hidcurrentmode.Value == "summary")
            {
                reportname = "HCLLPayrollSummary";
                fillgrid();
                rpthtml = bindheader("Payroll Summary Report", "10");

                rpthtml = rpthtml + @"<table align='left' cellpadding='5' width='100%' cellspacing='0' style='font-family: Calibri;
                        font-size: 12px; text-align: left;' border='0'><tr style='font-weight: bold; background: #395ba4; color: #ffffff;'>
<td style='width=38px;'width='100px'>S.No</td>
 <td>Month</td>
 <td>Total Employees</td>
<td>Total Salary</td>
<td>Total Earnings</td>
 <td>Total Deduction</td>
<td>Total Bonus</td>
<td>Gross Payment</td>
<td>Net Payment</td>
                                                                     
</tr>";
                for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
                {
                    rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["monthyear"].ToString() +
                              "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["totalemployee"].ToString() +

                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalsalary"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalearnings"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totaldeduction"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalbonus"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalgrosspayment"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["NetPayableAmount"].ToString() +

                              "</td></tr>";
                }
                rpthtml = rpthtml + "</table>";
            }



            else if (hidcurrentmode.Value == "empdetail")
            {
                fillemployeespayroll();
                reportname = "HCLLPayrollDetailReport";
                rpthtml    = bindheader("Payroll Detail Report", "14");

                rpthtml = rpthtml + @"<table align='left' cellpadding='5' width='100%' cellspacing='0' style='font-family: Calibri;
                        font-size: 12px; text-align: left;' border='0'><tr style='font-weight: bold; background: #395ba4; color: #ffffff;'>
<td style='width=38px;'width='100px'>S.No</td>
 <td>ID</td>
 <td>Employee</td>
<td>Start Date</td>
<td>End Date</td>
 <td>Total Salary</td>
<td>Total Earnings</td>
<td>Total Deduction</td>
<td>Bonus</td>
      <td>Gross Payment</td>  
   <td>Net Payment</td>    
 <td>Payment Status</td>     
<td>Payment Mode</td>  
<td>Check No.</td>                                                              
</tr>";
                for (int i = 0; i < dsexcel.Tables[0].Rows.Count; i++)
                {
                    rpthtml = rpthtml + "<tr><td>" + Convert.ToString(i + 1) + "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["loginid"].ToString() +
                              "</td>" + "<td>" + dsexcel.Tables[0].Rows[i]["empname"].ToString() +
                              "<td>" + dsexcel.Tables[0].Rows[i]["startdate"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["enddate"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalsalary"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totalearnings"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["totaldeduction"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["bonus"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["NetPayment"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["TotalAmount"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["paymentstatus"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["paymentmode"].ToString() +
                              "</td><td>" + dsexcel.Tables[0].Rows[i]["checkno"].ToString() +

                              "</td></tr>";
                }
                rpthtml = rpthtml + "</table>";
            }


            HtmlGenericControl divgen = new HtmlGenericControl();

            divgen.InnerHtml = rpthtml;
            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=\"" + reportname + ".xls\"");
            // create a string writer
            using (StringWriter sw = new StringWriter())
            {
                using (HtmlTextWriter htw = new HtmlTextWriter(sw))
                {
                    System.Web.UI.HtmlControls.HtmlGenericControl dv = new System.Web.UI.HtmlControls.HtmlGenericControl();
                    dv.InnerHtml = divgen.InnerHtml.Replace("border='0'", "border='1'");

                    dv.RenderControl(htw);
                    response.Write(sw.ToString());
                    response.End();
                }
            }
        }