Inheritance: System.Web.UI.HtmlControls.HtmlContainerControl
 protected override void OnPreInit(EventArgs e)
 {
     base.OnPreInit(e);
     foreach (Control control in Controls)
     {
         if (regForm == null)
         {
             regForm = control as HtmlForm;
             if (regForm != null) break;
         }
     }
     if (regForm == null)
     {
         throw new ArgumentException("登录页面中至少添加一个服务器端表单");
     }
     window = new Window();
     window.Title = "管理员注册";
     window.Closable = false;
     window.Icon = Icon.Key;
     window.Width = 320;
     window.Height = 185;
     formPanel = new FormPanel();
     formPanel.BodyStyle = "padding:20px;";
     formPanel.Layout = "table";
     formPanel.LayoutConfig.Add(new TableLayoutConfig()
     {
         Columns = 2
     });
     formPanel.Items.Add(new TextField()
     {
         FieldLabel = "用户名",
         AllowBlank = false,
         ColSpan = 2,
         Name = "Username"
     });
     formPanel.Items.Add(new TextField()
     {
         FieldLabel = "密码",
         AllowBlank = false,
         ColSpan = 2,
         InputType = Ext.Net.InputType.Password,
         Name = "Password"
     });
     formPanel.Items.Add(new TextField()
     {
         FieldLabel = "确认密码",
         AllowBlank = false,
         ColSpan = 1,
         InputType = Ext.Net.InputType.Password,
         Name = "Password2"
     });
     window.Items.Add(formPanel);
     regForm.Controls.Add(window);
     btnReg = new KeyAddButton();
     btnReg.Text = "注册";
     btnReg.ID = "btnReg";
     btnReg.OnClientClick = "App.direct.Reg({eventMask:{showMask:true,msg:'正在注册'}});";
     window.Buttons.Add(btnReg);
 }
        protected void Boton_Excel_Dios_Click(object sender, EventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

            Page page = new Page();
            HtmlForm form = new HtmlForm();
            GridView_Dios.DataSourceID = string.Empty;
            GridView_Dios.EnableViewState = false;
            GridView_Dios.AllowPaging = false;
            GridView_Dios.DataSource = LBPD.Logica_Mostrar_Precios();
            GridView_Dios.DataBind();
            page.EnableEventValidation = false;
            page.DesignerInitialize();
            page.Controls.Add(form);
            form.Controls.Add(GridView_Dios);
            page.RenderControl(htw);
            Response.Clear();
            Response.Buffer = true;
            Response.ContentType = "applicattion/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", "attachment;filename=data.xls");
            Response.Charset = "UTF-8";
            Response.ContentEncoding = Encoding.Default;
            Response.Write(sb.ToString());
            Response.End();
        }
Example #3
0
        public static void PrintWebControl(Control ControlToPrint, Control MyStyle)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ControlToPrint is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage);
                ((WebControl)ControlToPrint).Width = w;
            }
            System.Web.UI.Page pg = new System.Web.UI.Page();
            pg.EnableEventValidation = false;
            HtmlForm frm = new HtmlForm();

            frm.Controls.Add(MyStyle);

            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ControlToPrint);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);
            string strHTML = stringWrite.ToString();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write(strHTML);
            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();
        }
Example #4
0
        public void PrintWebControl(Control ControlToPrint)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ControlToPrint is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage);
                ((WebControl)ControlToPrint).Width = w;

            }

            Page pg = new Page();

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

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

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

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

            Response.Redirect("~/ListaImprez.aspx");
        }
Example #5
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            DataGridTest("GhtSubTest1", c_bounded(""));
            DataGridTest("GhtSubTest2", c_button(""));
            DataGridTest("GhtSubTest3", c_edit(""));
            DataGridTest("GhtSubTest4", c_hyper_link(""));
            DataGridTest("GhtSubTest5", c_template(""));
            DataGridTest("GhtSubTest6", c_bounded("/images/pic.gif"));
            DataGridTest("GhtSubTest7", c_button("/images/pic.gif"));
            DataGridTest("GhtSubTest8", c_edit("/images/pic.gif"));
            DataGridTest("GhtSubTest9", c_hyper_link("/images/pic.gif"));
            DataGridTest("GhtSubTest10", c_template("/images/pic.gif"));
            DataGridTest("GhtSubTest11", c_bounded("http://127.0.0.1/asd/asd/../../asd.asd"));
            DataGridTest("GhtSubTest12", c_button("http://127.0.0.1/asd/asd/../../asd.asd"));
            DataGridTest("GhtSubTest13", c_edit("http://127.0.0.1/asd/asd/../../asd.asd"));
            DataGridTest("GhtSubTest14", c_hyper_link("http://127.0.0.1/asd/asd/../../asd.asd"));
            DataGridTest("GhtSubTest15", c_template("http://127.0.0.1/asd/asd/../../asd.asd"));
            DataGridTest("GhtSubTest16", c_bounded(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
            DataGridTest("GhtSubTest17", c_button(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
            DataGridTest("GhtSubTest18", c_edit(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
            DataGridTest("GhtSubTest19", c_hyper_link(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));
            DataGridTest("GhtSubTest20", c_template(@"asdd://asd?//.\.\.\././..\/\/\/\/././zxc.zxc"));


            GHTTestEnd();
        }
Example #6
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here
            try
            {
                System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
                GHTTestBegin(frm);

                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlButton), "HTMLButton_InnerHTML_1", "sample text");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlAnchor), "HTMLAnchor_InnerHTML_1", "sample text");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlTextArea), "HtmlTextArea_InnerHTML_1", "sample text");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlGenericControl), "HtmlGenericControl_InnerHTML_1", "sample text");

                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlButton), "HTMLButton_InnerHTML_2", "other text: ~!@#$%^&*()_+");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlAnchor), "HTMLAnchor_InnerHTML_2", "other text: ~!@#$%^&*()_+");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlTextArea), "HtmlTextArea_InnerHTML_2", "other text: ~!@#$%^&*()_+");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlGenericControl), "HtmlGenericControl_InnerHTML_2", "other text: ~!@#$%^&*()_+");

                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlButton), "HTMLButton_InnerHTML_3", "<b>Bold</b>");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlAnchor), "HTMLAnchor_InnerHTML_3", "<b>Bold</b>");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlTextArea), "HtmlTextArea_InnerHTML_3", "<b>Bold</b>");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlGenericControl), "HtmlGenericControl_InnerHTML_3", "<b>Bold</b>");

                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlButton), "HTMLButton_InnerHTML_5", "");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlAnchor), "HTMLAnchor_InnerHTML_5", "");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlTextArea), "HtmlTextArea_InnerHTML_5", "");
                TestInnerHTMLControl(typeof(System.Web.UI.HtmlControls.HtmlGenericControl), "HtmlGenericControl_InnerHTML_5", "");
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            DataGridTest("GhtSubTest1", c_bounded(""));
            DataGridTest("GhtSubTest2", c_button(""));
            DataGridTest("GhtSubTest3", c_edit(""));
            DataGridTest("GhtSubTest4", c_hyper_link(""));
            DataGridTest("GhtSubTest5", c_template(""));
            DataGridTest("GhtSubTest6", c_bounded("ID"));
            DataGridTest("GhtSubTest7", c_button("ID"));
            DataGridTest("GhtSubTest8", c_edit("ID"));
            DataGridTest("GhtSubTest9", c_hyper_link("ID"));
            DataGridTest("GhtSubTest10", c_template("ID"));
            DataGridTest("GhtSubTest11", c_bounded("test string"));
            DataGridTest("GhtSubTest12", c_button("test string"));
            DataGridTest("GhtSubTest13", c_edit("test string"));
            DataGridTest("GhtSubTest14", c_hyper_link("test string"));
            DataGridTest("GhtSubTest15", c_template("test string"));

            GHTTestEnd();
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)FindControl("Form1");
     GHTTestBegin(frm);
     // Need more testing on different
     // application paths. Needs for that multiple virtual directories
     this.GHTSubTestBegin("AcceptedTypes1");
     try
     {
         string[] textArray1 = this.Request.AcceptTypes;
         int      num2       = textArray1.Length - 1;
         for (int num1 = 0; num1 <= num2; num1++)
         {
             string[] textArray2 = new string[] { "Accept Type ", num1.ToString(), ": ", textArray1[num1], "<br>" };
             this.GHTSubTestAddResult(string.Concat(textArray2));
         }
     }
     catch (Exception exception2)
     {
         // ProjectData.SetProjectError(exception2);
         Exception exception1 = exception2;
         this.GHTSubTestAddResult("unxpected " + exception1.GetType().Name + " exception was caught-" + exception1.Message);
         // ProjectData.ClearProjectError();
     }
     this.GHTSubTestEnd();
     this.GHTTestEnd();
 }
Example #9
0
        public static void PrintWebControl(Control ctrl, string Script)
        {
            StringWriter stringWrite = new StringWriter();
            System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
            if (ctrl is WebControl)
            {
                Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
            }
            Page pg = new Page();
            pg.EnableEventValidation = false;
            pg.StyleSheetTheme = "../CSS/order.css";
            if (Script != string.Empty)
            {
                pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
            }

            HtmlLink link = new HtmlLink();
            link.Href = "../CSS/order.css";
            HtmlForm frm = new HtmlForm();
            pg.Controls.Add(frm);
            frm.Attributes.Add("runat", "server");
            frm.Controls.Add(ctrl);
            pg.DesignerInitialize();
            pg.RenderControl(htmlWrite);
            string strHTML = stringWrite.ToString();
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.Write("<head runat='server'> <title>Printer - Bản in tại Support.evnit.evn.com.vn</title> <link type='text/css' rel='stylesheet' href='../CSS/order.css'><link type='text/css' rel='stylesheet' href='../CSS/style.css'></head>");
            HttpContext.Current.Response.Write(strHTML);
            HttpContext.Current.Response.Write("<script>window.print();</script>");
            HttpContext.Current.Response.End();
        }
        protected void btnexporttoexc_Click(object sender, EventArgs e)
        {
            try
            {
                string sysDates = DateTime.Now.ToString("dd/MM/yyyy");
                string FileName = sysDates;
                string strFileName = FileName + ".xls";
                btnSearch_Click(sender, e);
                //GridViewExportUtil.ExportExcell(strFileName, Grdiworkreg);

                string attachment = "attachment; filename=" + strFileName + " ";
                Response.ClearContent();
                Response.AddHeader("content-disposition", attachment);
                Response.ContentType = "application/ms-excel";

                StringWriter sw = new StringWriter();
                HtmlTextWriter htw = new HtmlTextWriter(sw);

                HtmlForm frm = new HtmlForm();
                GridView2.AllowPaging = false;

                GridView2.Parent.Controls.Add(frm);
                frm.Attributes["runat"] = "server";
                frm.Controls.Add(GridView2);
                frm.RenderControl(htw);

                Response.Write(sw.ToString());
                Response.End();
            }
            catch (Exception ex)
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "alert", "alert('" + ex.Message + "');", true);
            }
        }
Example #11
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable(1, 3);
                DataGrid1.DataBind();;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest2;
            try
            {
                DataGrid2.DataSource = GHTTests.GHDataSources.DSDataTable(1, 3);
                DataGrid2.DataBind();;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
Example #12
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                Image1.CausesValidation = false;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest2;
            try
            {
                Image2.CausesValidation = true;
                GHTSubTestAddResult(Image2.CausesValidation.ToString());
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
Example #13
0
    protected void ButtonDownload_Click(object sender, EventArgs e)
    {
        string filename = String.Format("Results_{0}_{1}.xls", DateTime.Today.Month.ToString(), DateTime.Today.Year.ToString());

        if (!string.IsNullOrEmpty(GridView1.Page.Title))
        {
            filename = "Export_" + DateTime.Today.ToString() + ".xls";
        }

        HttpContext.Current.Response.Clear();

        HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + filename);


        HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
        HttpContext.Current.Response.Charset     = "";

        System.IO.StringWriter       stringWriter = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWriter   = new HtmlTextWriter(stringWriter);



        System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
        GridView1.Parent.Controls.Add(form);
        form.Controls.Add(GridView1);
        form.RenderControl(htmlWriter);

        HttpContext.Current.Response.Write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" />");
        HttpContext.Current.Response.Write(stringWriter.ToString());
        HttpContext.Current.Response.End();
    }
Example #14
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                Repeater1.DataSource = GHTTests.GHDataSources.DSArrayList();
                Repeater1.DataBind();
                GHTSubTestAddResult(Repeater1.Items.GetType().ToString());
                foreach (RepeaterItem item in Repeater1.Items)
                {
                    GHTSubTestAddResult(item.ItemIndex + "," + item.ItemType.ToString() + "," + ((DataBoundLiteralControl)item.Controls[0]).Text);
                }
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTSubTestBegin("GHTSubTest1");
            try
            {
                Application.Clear();
                Application["var1"] = "variable1";
                Application["var2"] = "variable2";
                Application["var3"] = "variable3";

                Application.RemoveAll();

                int num2 = this.Application.Count - 1;
                for (int num1 = 0; num1 <= num2; num1++)
                {
                    this.GHTSubTestAddResult((string)("Application.Item(" + num1.ToString() + ") = " + this.Application[num1]));
                }
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTSubTestEnd();
        }
Example #16
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable(0, 1, "http://");
                System.Web.UI.WebControls.HyperLinkColumn c_id      = new System.Web.UI.WebControls.HyperLinkColumn();
                System.Web.UI.WebControls.HyperLinkColumn c_name    = new System.Web.UI.WebControls.HyperLinkColumn();
                System.Web.UI.WebControls.HyperLinkColumn c_company = new System.Web.UI.WebControls.HyperLinkColumn();

                c_id.DataTextField             = "ID";
                c_id.NavigateUrl               = "http://www.google.com";
                c_name.DataTextField           = "Name";
                c_name.DataNavigateUrlField    = "Name";
                c_company.DataTextField        = "Company";
                c_company.DataNavigateUrlField = "Company";

                DataGrid1.Columns.Add(c_id);
                DataGrid1.Columns.Add(c_name);
                DataGrid1.Columns.Add(c_company);

                DataGrid1.DataBind();;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
Example #17
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTSubTestBegin("GHTSubTest1");
            try
            {
                Session.Clear();

                Session["v1"] = "value1";
                Session["v2"] = "value2";
                Session["v3"] = "value3";

                IEnumerator enumerator1 = this.Session.Keys.GetEnumerator();
                while (enumerator1.MoveNext())
                {
                    string text1 = (string)(enumerator1.Current);
                    this.GHTSubTestAddResult((string)("Session(\"" + text1 + "\") = " + this.Session[text1]));
                }
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTSubTestEnd();
        }
Example #18
0
        public static void xlsport(GridView grd, string _fnm, Page p)
        {
            grd.Visible = true;
            gridstrip(grd);    
            grd.DataBind();

            HtmlForm form = new HtmlForm();
            string attachment = "attachment; filename=" + _fnm + csclass.ranfn() + ".xls";

            HttpContext.Current.Response.ClearContent();
            HttpContext.Current.Response.AddHeader("content-disposition", attachment);
            HttpContext.Current.Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
            p.EnableViewState = false;
            HttpContext.Current.Response.Charset = string.Empty;

            System.IO.StringWriter stw = new System.IO.StringWriter();
            HtmlTextWriter htextw = new HtmlTextWriter(stw);

            form.Controls.Add(grd);
            p.Controls.Add(form);

            form.RenderControl(htextw);
            HttpContext.Current.Response.Write(stw.ToString());
            HttpContext.Current.Response.End();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest5;
            try
            {
                TEXTAREA5.Name = "nameOfTextArea";
                GHTSubTestAddResult(TEXTAREA5.Name);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest6;
            try
            {
                Textarea6.Name = "123";
                GHTSubTestAddResult(Textarea6.Name);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTSubTestBegin("GHTSubTest1");
            try
            {
                GHTSubTestAddResult(Session.Contents.GetType().ToString());
                if (Equals(Session, Session.Contents))
                {
                    GHTSubTestAddResult("Objects are equal");
                }
                else
                {
                    GHTSubTestAddResult("Objects are not equal");
                }
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTSubTestEnd();

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

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

            page.EnableEventValidation = false;

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

            page.RenderControl(htw);

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

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

            Response.Write(sb.ToString());
            Response.End();
        }
Example #22
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here
            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = Ghtsubtest3;;
            try
            {
                anchor3.Name = "name_anchor3";
                GHTSubTestAddResult(anchor3.Name);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTActiveSubTest = Ghtsubtest4;;
            try
            {
                anchor4.Name = "123";
                GHTSubTestAddResult(anchor4.Name);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)FindControl("Form1");
            GHTTestBegin(frm);

            GHTSubTestBegin("Request.CurrentExecutionFilePath1");
            try
            {
                GHTSubTestAddResult(Request.CurrentExecutionFilePath);
            }
            catch (Exception ex)
            {
                GHTSubTestAddResult("unxpected " + ex.GetType().Name + " exception was caught-" + ex.Message);
            }

            GHTSubTestEnd();

            // we pring the File Path as well to see that they are equasll
            // we alsi call this page from HttpRequest_CurrentExecutionFilePath_1
            // to see the difference
            GHTSubTestBegin("Request.FilePath1");
            try
            {
                GHTSubTestAddResult(Request.FilePath);
            }
            catch (Exception ex)
            {
                GHTSubTestAddResult("unxpected " + ex.GetType().Name + " exception was caught-" + ex.Message);
            }

            GHTSubTestEnd();
            GHTTestEnd();
        }
        public static string RenderControl(string path, string propertyName, object propertyValue)
        {
            Page pageHolder = new Page();
            pageHolder.EnableEventValidation = false;

            UserControl viewControl =
                (UserControl)pageHolder.LoadControl(path);

            if (propertyValue != null)
            {
                Type viewControlType = viewControl.GetType();
                PropertyInfo property =
                    viewControlType.GetProperty(propertyName);

                if (property != null)
                {
                    property.SetValue(viewControl, propertyValue, null);
                }
                else
                {
                    throw new Exception(string.Format(
                        "UserControl: {0} does not have a public {1} property.", path, propertyName));
                }
            }

            HtmlForm _form = new HtmlForm();
            pageHolder.Controls.Add(_form);
            _form.Controls.Add(viewControl);

            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);                          
            return output.ToString();
        }
Example #25
0
 public static void PrintWebControl(Control ctrl, string Script)
 {
     StringWriter stringWrite = new StringWriter();
     System.Web.UI.HtmlTextWriter htmlWrite = new System.Web.UI.HtmlTextWriter(stringWrite);
     if (ctrl is WebControl)
     {
         Unit w = new Unit(100, UnitType.Percentage); ((WebControl)ctrl).Width = w;
     }
     Page pg = new Page();
     pg.EnableEventValidation = false;
     if (Script != string.Empty)
     {
         pg.ClientScript.RegisterStartupScript(pg.GetType(), "PrintJavaScript", Script);
     }
     HtmlForm frm = new HtmlForm();
     pg.Controls.Add(frm);
     frm.Attributes.Add("runat", "server");
     frm.Controls.Add(ctrl);
     pg.DesignerInitialize();
     pg.RenderControl(htmlWrite);
     string strHTML = stringWrite.ToString();
     HttpContext.Current.Response.Clear();
     HttpContext.Current.Response.Write(strHTML);
     HttpContext.Current.Response.Write("<script>window.print();</script>");
     HttpContext.Current.Response.End();
 }
 /// <summary>
 /// Export Products data to Excel
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void btnExport_Click(object sender, EventArgs e)
 {
     try
     {
         gdvInboundProducts.Columns[gdvInboundProducts.Columns.Count - 1].Visible = false;
         gdvInboundProducts.AllowPaging = false;
         gdvInboundProducts.EditIndex   = -1;
         GetProducts();
         Response.Clear();
         Response.AddHeader("content-disposition", "attachment;filename=InboudTracking.xls");
         Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
         StringWriter   stringWrite = new StringWriter();
         HtmlTextWriter htmlWrite   = new HtmlTextWriter(stringWrite);
         System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
         Controls.Add(form);
         form.Controls.Add(gdvInboundProducts);
         form.RenderControl(htmlWrite);
         Response.Write(stringWrite.ToString());
         Response.End();
         gdvInboundProducts.Columns[gdvInboundProducts.Columns.Count - 1].Visible = true;
         gdvInboundProducts.AllowPaging = true;
     }
     catch (Exception ex)
     {
         EventLogProvider.LogException("Export data to excel", "btnExport_Click()", ex, CurrentSite.SiteID, ex.Message);
     }
 }
        protected void imgBtnExportarExcelEjecucion_Click(object sender, ImageClickEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);
            Page page = new Page();
            HtmlForm form = new HtmlForm();

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

            page.EnableEventValidation = false;

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

            page.RenderControl(htw);

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

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

            Response.Write(sb.ToString());
            Response.End();
        }
Example #28
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                Repeater1.DataSource = GHTTests.GHDataSources.DSArray();
                Repeater1.DataBind();
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTSubTestBegin("Code base constructor 1");
            try
            {
                System.Web.UI.WebControls.Repeater Repeater2 = new System.Web.UI.WebControls.Repeater();
                GHTActiveSubTest.Controls.Add(Repeater2);
                Repeater2.DataSource   = GHTTests.GHDataSources.DSArrayList();
                Repeater2.ItemTemplate = new t_DBLitTemplate();
                Repeater2.DataBind();
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTSubTestEnd();

            GHTTestEnd();
        }
        public static string RenderControl(string path, object data)
        {
            Page pageHolder = new Page();
            pageHolder.EnableEventValidation = false;

            UserControl viewControl = (UserControl)pageHolder.LoadControl(path);
            if (data != null)
            {
                Type viewControlType = viewControl.GetType();
                FieldInfo field = viewControlType.GetField("Data");

                if (field != null)
                {
                    field.SetValue(viewControl, data);
                }
                else
                {
                    throw new Exception("View file: " + path + " does not have a public Data property");
                }
            }
            
            HtmlForm _form = new HtmlForm();
            pageHolder.Controls.Add(_form);
            _form.Controls.Add(viewControl);

            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pageHolder, output, false);           
            return output.ToString();
        }
 private void Page_Load(object sender, System.EventArgs e)
 {
     System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)FindControl("Form1");
     GHTTestBegin(frm);
     //False
     GHTSubTestBegin("Causes validation = false");
     try
     {
         System.Web.UI.HtmlControls.HtmlInputButton btn = new System.Web.UI.HtmlControls.HtmlInputButton();
         btn.CausesValidation = false;
         GHTActiveSubTest.Controls.Add(btn);
     }
     catch (Exception ex)
     {
         GHTSubTestUnexpectedExceptionCaught(ex);
     }
     //true
     GHTSubTestBegin("Causes validation = true");
     try
     {
         System.Web.UI.HtmlControls.HtmlInputButton btn = new System.Web.UI.HtmlControls.HtmlInputButton();
         btn.CausesValidation = true;
         GHTActiveSubTest.Controls.Add(btn);
     }
     catch (Exception ex)
     {
         GHTSubTestUnexpectedExceptionCaught(ex);
     }
     GHTTestEnd();
 }
Example #31
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                Repeater1.DataSource = GHTTests.GHDataSources.DSArrayList();
                Repeater1.DataBind();

                IEnumerator items = Repeater1.Items.GetEnumerator();
                System.Web.UI.WebControls.RepeaterItem item;

                while (items.MoveNext())
                {
                    item = (RepeaterItem)items.Current;
                    GHTSubTestAddResult(item.ItemIndex.ToString());
                }
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest3;
            try
            {
                Image3.Src = "/image.jpg";
                GHTSubTestAddResult(Image3.Src);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest4;
            try
            {
                Image4.Src = "/123";
                GHTSubTestAddResult(Image4.Src);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here
            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)FindControl("Form1");
            GHTTestBegin(frm);
            // ===================================
            // testing if the headers object is set
            // ===================================
            GHTSubTestBegin("AppDomainAppPath");
            try
            {
                string s1;
                s1 = HttpRuntime.AppDomainAppPath;
                s1 = s1.Replace("\\", "/");
                s1 = s1.Replace("C:", "c:");
                GHTSubTestAddResult(s1);
            }
            catch (Exception ex)
            {
                GHTSubTestAddResult("unxpected " + ex.GetType().Name + " exception was caught-" + ex.Message);
            }

            GHTSubTestEnd();
            GHTTestEnd();
        }
Example #34
0
    protected void btnArchivo_Click(object sender, EventArgs e)
    {
        string Hora = DateTime.Now.ToString("dd_MM_yyy_HH_mm");

        grid = new GridView();
        cn.Open();
        string cmd2 = "SELECT ClasePlantilla.ClasePlantillaID as ClasePlantillaID, " +
                      " dbo.Clase.ClaseDescripcion as ClaseDescripcion, " +
                      " dbo.Cliente.ClienteNombre as ClienteDescripcion, " +
                      " ClasePlantilla.ClasePlantillaHora as ClasePlantillaHora, " +
                      " ClasePlantilla.ClasePlantillaCupo as ClasePlantillaCupo," +
                      " ClasePlantilla.ClasePlantillaActiva as ClasePlantillaActiva," +
                      " ClasePlantilla.ClaseID as ClaseID, " +
                      " ClasePlantilla.ProfesorID as ProfesorID," +
                      " ClasePlantilla.ClasePlantillaFecha as ClasePlantillaFecha," +
                      " ClasePlantilla.ClienteID as ClienteID, " +
                      " dbo.Usuario.UsuarioNombre as UsuarioNombre, " +
                      " dbo.Usuario.UsuarioApellido as UsuarioApellido" +
                      " FROM dbo.Clase INNER JOIN" +
                      " ClasePlantilla ON dbo.Clase.ClaseID = ClasePlantilla.ClaseID INNER JOIN" +
                      " dbo.Cliente ON ClasePlantilla.ClienteID = dbo.Cliente.ClienteID INNER JOIN" +
                      " dbo.Usuario ON ClasePlantilla.ProfesorID = dbo.Usuario.UsuarioID";

        dAdapter = new SqlDataAdapter(cmd2, cn);
        DataSet ds = new DataSet();

        dAdapter.Fill(ds);
        dt = ds.Tables[0];
        string[] TablaID = new string[1];
        TablaID[0]        = "ClasePlantillaID";
        grid.DataKeyNames = TablaID;
        grid.DataSource   = dt;
        grid.DataBind();
        cn.Close();
        System.Text.StringBuilder sb  = new System.Text.StringBuilder();
        System.IO.StringWriter    sw  = new System.IO.StringWriter(sb);
        HtmlTextWriter            htw = new HtmlTextWriter(sw);
        Page page = new Page();

        System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
        GridView Grid = new GridView();

        grid.AllowPaging = false;
        grid.DataBind();
        grid.EnableViewState       = false;
        page.EnableEventValidation = false;
        page.DesignerInitialize();
        page.Controls.Add(form);
        form.Controls.Add(grid);
        page.RenderControl(htw);
        Response.Clear();
        Response.Buffer      = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment;filename=plantilla_clase_" + Hora + ".xls");
        Response.Charset         = "UTF-8";
        Response.ContentEncoding = System.Text.Encoding.Default;
        Response.Write(sb.ToString());
        Response.End();
    }
Example #35
0
    protected void btnArchivo_Click(object sender, EventArgs e)
    {
        string Hora = DateTime.Now.ToString("dd_MM_yyy_HH_mm");

        grid = new GridView();
        cn.Open();
        string cmd2 = "SELECT   " +
                      " Clase.ClaseDescripcion as ClaseDescripcion, " +
                      " ClasePlantilla.ClasePlantillaFecha as ClasePlantillaFecha, " +
                      " ClasePlantilla.ClasePlantillaHora as ClasePlantillaHora, " +
                      " Reserva.FechaReserva as FechaReserva, " +
                      " (SELECT UsuarioNombre FROM Usuario Where UsuarioID = Reserva.UsuarioID) as Usuario, " +
                      " (SELECT UsuarioCorreo FROM Usuario WHERE UsuarioID = Reserva.UsuarioID) as Correo, " +
                      " (SELECT UsuarioCelular1 FROM Usuario WHERE UsuarioID = Reserva.UsuarioID) as Celular, " +
                      " (SELECT UsuarioNombre+' '+UsuarioApellido FROM Usuario Where UsuarioID = Reserva.UsuarioID) as Usuario, " +
                      " (SELECT UsuarioNombre+' '+UsuarioApellido FROM Usuario Where UsuarioID = ClasePlantilla.ProfesorID) as Profesor, " +
                      " (SELECT UsuarioCedula FROM Usuario Where UsuarioID = ClasePlantilla.ProfesorID) as ProfesorCedula " +
                      " FROM  Clase INNER JOIN" +
                      " ClasePlantilla ON Clase.ClaseID = ClasePlantilla.ClaseID INNER JOIN" +
                      " Reserva ON ClasePlantilla.ClasePlantillaID = Reserva.ClasePlantillaID " + ViewState["sWhere"] + " " +
                      " " + ViewState["FiltroBusqueda"] + " " + ViewState["FiltroBusqueda1"] +
                      " ORDER BY ClasePlantilla.ClasePlantillaFecha ASC, ClasePlantilla.ClasePlantillaHora ASC, ClasePlantilla.ProfesorID ASC";
        SqlDataAdapter dAdapter = new SqlDataAdapter(cmd2, cn);
        DataSet        ds       = new DataSet();

        dAdapter.Fill(ds);
        dt = ds.Tables[0];
        string[] TablaID = new string[1];
        TablaID[0]        = "ClaseDescripcion";
        grid.DataKeyNames = TablaID;
        grid.DataSource   = dt;
        grid.DataBind();
        cn.Close();
        System.Text.StringBuilder sb  = new System.Text.StringBuilder();
        System.IO.StringWriter    sw  = new System.IO.StringWriter(sb);
        HtmlTextWriter            htw = new HtmlTextWriter(sw);
        Page page = new Page();

        System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
        GridView Grid = new GridView();

        grid.AllowPaging = false;
        grid.DataBind();
        grid.EnableViewState       = false;
        page.EnableEventValidation = false;
        page.DesignerInitialize();
        page.Controls.Add(form);
        form.Controls.Add(grid);
        page.RenderControl(htw);
        Response.Clear();
        Response.Buffer      = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment;filename=reservas_" + Hora + ".xls");
        Response.Charset         = "UTF-8";
        Response.ContentEncoding = System.Text.Encoding.Default;
        Response.Write(sb.ToString());
        Response.End();
    }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable(1, 3);
                DataGrid1.SelectedIndex = 3;
                DataGrid1.DataBind();;
                GHTSubTestAddResult(DataGrid1.SelectedIndex.ToString());
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest2;
            try
            {
                DataGrid2.DataSource = GHTTests.GHDataSources.DSDataTable(1, 3);
                DataGrid2.SelectedIndex = 77;
                DataGrid2.DataBind();;
                GHTSubTestAddResult(DataGrid2.SelectedIndex.ToString());
                //GHTSubTestExpectedExceptionNotCaught("HttpException");
            }
            catch (HttpException eex)
            {
                GHTSubTestExpectedExceptionCaught(eex);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = GHTSubTest3;
            try
            {
                DataGrid3.DataSource = GHTTests.GHDataSources.DSDataTable(1, 3);
                DataGrid3.SelectedIndex = -3;
                DataGrid3.DataBind();;
                GHTSubTestAddResult(DataGrid3.SelectedIndex.ToString());
                GHTSubTestExpectedExceptionNotCaught("ArgumentOutOfRangeException");
            }
            catch (ArgumentOutOfRangeException eex)
            {
                GHTSubTestExpectedExceptionCaught(eex);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
Example #37
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;;
            try
            {
                GHTSubTestAddResult(A1.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTActiveSubTest = GHTSubTest2;;
            try
            {
                GHTSubTestAddResult(A2.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTActiveSubTest = GHTSubTest3;;
            try
            {
                A3.Target = "_self";
                GHTSubTestAddResult(A3.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTActiveSubTest = GHTSubTest4;;
            try
            {
                A4.Target = "123";
                GHTSubTestAddResult(A4.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }
            GHTActiveSubTest = GHTSubTest5;;
            try
            {
                A5.Target = "";
                GHTSubTestAddResult(A5.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable();
                System.Web.UI.WebControls.HyperLinkColumn c_id      = new System.Web.UI.WebControls.HyperLinkColumn();
                System.Web.UI.WebControls.HyperLinkColumn c_name    = new System.Web.UI.WebControls.HyperLinkColumn();
                System.Web.UI.WebControls.HyperLinkColumn c_company = new System.Web.UI.WebControls.HyperLinkColumn();

                c_id.DataTextField      = "ID";
                c_id.NavigateUrl        = "http://www.example.com";
                c_id.Target             = "";
                c_name.DataTextField    = "Name";
                c_name.NavigateUrl      = "http://www.example.com";
                c_name.Target           = "_blank";
                c_company.DataTextField = "Company";
                c_company.NavigateUrl   = "http://www.example.com";
                c_company.Target        = "skjfh skjf hkjd";

                DataGrid1.Columns.Add(c_id);
                DataGrid1.Columns.Add(c_name);
                DataGrid1.Columns.Add(c_company);

                DataGrid1.DataBind();;

                GHTSubTestAddResult(c_id.Target);
                GHTSubTestAddResult(c_name.Target);
                GHTSubTestAddResult(c_company.Target);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = Ghtsubtest2;
            try
            {
                DataGrid2.DataSource = GHTTests.GHDataSources.DSDataTable();
                DataGrid2.DataBind();;

                GHTSubTestAddResult(((System.Web.UI.WebControls.HyperLinkColumn)DataGrid2.Columns[0]).NavigateUrl);
                GHTSubTestAddResult(((System.Web.UI.WebControls.HyperLinkColumn)DataGrid2.Columns[1]).NavigateUrl);
                GHTSubTestAddResult(((System.Web.UI.WebControls.HyperLinkColumn)DataGrid2.Columns[2]).NavigateUrl);
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTTestEnd();
        }
Example #39
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            //Put user code to initialize the page here

            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)this.FindControl("Form1");
            GHTTestBegin(frm);

            GHTActiveSubTest = GHTSubTest1;
            try
            {
                DataGrid1.DataSource = GHTTests.GHDataSources.DSDataTable();
                System.Web.UI.WebControls.TemplateColumn c1 = new System.Web.UI.WebControls.TemplateColumn();
                System.Web.UI.WebControls.TemplateColumn c2 = new System.Web.UI.WebControls.TemplateColumn();
                System.Web.UI.WebControls.TemplateColumn c3 = new System.Web.UI.WebControls.TemplateColumn();
                System.Web.UI.WebControls.TemplateColumn c4 = new System.Web.UI.WebControls.TemplateColumn();
                System.Web.UI.WebControls.TemplateColumn c5 = new System.Web.UI.WebControls.TemplateColumn();

                c1.ItemTemplate = new t_DBLitTemplate();
                c2.ItemTemplate = new t_DBLitTemplate();
                c3.ItemTemplate = new t_DBLitTemplate();
                c4.ItemTemplate = new t_DBLitTemplate();
                c5.ItemTemplate = new t_DBLitTemplate();

                c1.EditItemTemplate = new t_EmptyLitTemplate();
                c2.EditItemTemplate = new t_PlainTextLitTemplate();
                c3.EditItemTemplate = new t_HtmlLitTemplate();
                c4.EditItemTemplate = new t_ControlLitTemplate();
                c5.EditItemTemplate = new t_DBLitTemplate();

                DataGrid1.Columns.Add(c1);
                DataGrid1.Columns.Add(c2);
                DataGrid1.Columns.Add(c3);
                DataGrid1.Columns.Add(c4);
                DataGrid1.Columns.Add(c5);

                DataGrid1.EditItemIndex = 2;
                DataGrid1.DataBind();;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

            GHTActiveSubTest = Ghtsubtest2;
            try
            {
                DataGrid2.DataSource    = GHTTests.GHDataSources.DSDataTable();
                DataGrid2.EditItemIndex = 2;
                DataGrid2.DataBind();;
            }
            catch (Exception ex)
            {
                GHTSubTestUnexpectedExceptionCaught(ex);
            }

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

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

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

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

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

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

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

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

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

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

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

                //Habilito el buffer
                Response.Buffer = true;

                //Asigno el tipo de contenido
                Response.ContentType = "application/vnd.ms-excel";
                //Asigno el nombre del documento a exportar en el header del response
                Response.AddHeader("Content-Disposition", "attachment;filename=Plan_Operativo.xls");
                //Asigno el tipo de charset "UTF-8"
                Response.Charset = "UTF-8";
                //Establesco la configuracion por defecto para la codificacion
                Response.ContentEncoding = Encoding.Default;
                //Realizo el proceso de escritura para el objeto objsb
                Response.Write(objsb.ToString());
                //Finalizo la respuesta
                Response.End();
                return true;
            }
            catch (Exception) { return false; }
        }
Example #41
0
    protected void btnDescargar_Click(object sender, ImageClickEventArgs e)
    {
        string   Hora = DateTime.Now.ToString("dd_MM_yyy_HH_mm");
        GridView grid = new GridView();

        cn.Open();
        string cmd2 = " SELECT DISTINCT(dbo.Usuario.UsuarioID) as UsuarioID,  " +
                      " (dbo.Usuario.UsuarioNombre+' '+dbo.Usuario.UsuarioApellido) as UsuarioNombre, dbo.Usuario.UsuarioCedula," +
                      " (SELECT ClienteNombre FROM Cliente WHERE ClienteID =  dbo.UsuarioRol.ClienteID) as Empresa," +
                      " (select COUNT(*) from Reserva WHERE MONTH(FechaReserva) = MONTH(SYSDATETIME()) AND YEAR(FechaReserva) = YEAR(SYSDATETIME()) AND UsuarioId = dbo.Usuario.UsuarioID) as NroReservas," +
                      " (select COUNT(*) from Reserva WHERE MONTH(FechaReserva) = MONTH(SYSDATETIME()) - 1 AND YEAR(FechaReserva) = YEAR(SYSDATETIME()) AND UsuarioId = dbo.Usuario.UsuarioID) as NroReservasAnt," +
                      " CAST(CASE WHEN dbo.PlanEmpresa.PlanActivo = 1 THEN 'ACTIVO' ELSE 'INACTIVO' END as VARCHAR(10)) as EstadoAct, " +
                      " CAST(CASE WHEN dbo.PlanEmpresa.EstadoProximo = 1 THEN 'ACTIVO' ELSE 'INACTIVO' END as VARCHAR(10)) as EstadoSig, " +
                      " (select top 1 p.plannombre from planalumno pa join [plan] p on pa.planID = p.PlanId and pa.UsuarioID = dbo.Usuario.UsuarioID order by pa.PlanAlumnoID desc) as PlanNombre," +
                      " (select top 1 TotalClases from planempresa where usuarioid = dbo.Usuario.UsuarioID order by planempresaid desc) as NroClases" +
                      " FROM  dbo.PlanEmpresa INNER JOIN " +
                      " dbo.Usuario ON dbo.PlanEmpresa.UsuarioID = dbo.Usuario.UsuarioID INNER JOIN " +
                      " dbo.UsuarioRol ON dbo.Usuario.UsuarioID = dbo.UsuarioRol.UsuarioID " +
                      " WHERE dbo.UsuarioRol.ClienteID != 1 " + ViewState["sWhere"] + ViewState["sWhere2"] + ViewState["sWhere3"] +
                      " ORDER BY Empresa ASC";
        SqlDataAdapter dAdapter = new SqlDataAdapter(cmd2, cn);
        DataSet        ds       = new DataSet();

        dAdapter.Fill(ds);
        dt = ds.Tables[0];
        string[] TablaID = new string[1];
        TablaID[0]        = "UsuarioCedula";
        grid.DataKeyNames = TablaID;
        grid.DataSource   = dt;
        grid.DataBind();
        cn.Close();
        System.Text.StringBuilder sb  = new System.Text.StringBuilder();
        System.IO.StringWriter    sw  = new System.IO.StringWriter(sb);
        HtmlTextWriter            htw = new HtmlTextWriter(sw);
        Page page = new Page();

        System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
        GridView Grid = new GridView();

        grid.AllowPaging = false;
        grid.DataBind();
        grid.EnableViewState       = false;
        page.EnableEventValidation = false;
        page.DesignerInitialize();
        page.Controls.Add(form);
        form.Controls.Add(grid);
        page.RenderControl(htw);
        Response.Clear();
        Response.Buffer      = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment;filename=Reporte_Usuarios_Estado_" + Hora + ".xls");
        Response.Charset         = "UTF-8";
        Response.ContentEncoding = System.Text.Encoding.Default;
        Response.Write(sb.ToString());
        Response.End();
    }
Example #42
0
        private void Page_Load(object sender, System.EventArgs e)
        {
            System.Web.UI.HtmlControls.HtmlForm frm = (HtmlForm)FindControl("Form1");
            GHTTestBegin(frm);

            Label1.Text = "Page_Load Event was raised";

            GHTSubTestEnd();
            GHTTestEnd();
        }
Example #43
0
    protected void ImgbtnArchivo_Click(object sender, ImageClickEventArgs e)
    {
        string Hora = DateTime.Now.ToString("dd_MM_yyy_HH_mm");

        grid = new GridView();
        cn.Open();
        string cmd2 = "SELECT  " +
                      " (SELECT UsuarioNombre+' '+UsuarioApellido FROM Usuario WHERE UsuarioID = dbo.Reserva.UsuarioID) as UsuarioNombre, " +
                      " (SELECT UsuarioCedula FROM Usuario WHERE UsuarioID = dbo.Reserva.UsuarioID) as UsuarioCedula, " +
                      " dbo.Clase.ClaseDescripcion as ClaseDescripcion, " +
                      " (dbo.ClasePlantilla.ClasePlantillaFecha+' '+dbo.ClasePlantilla.ClasePlantillaHora) as ClaseFecha,  " +
                      " dbo.Cliente.ClienteNombre as ClienteNombre " +
                      " FROM dbo.Reserva INNER JOIN " +
                      " dbo.ClasePlantilla ON dbo.Reserva.ClasePlantillaID = dbo.ClasePlantilla.ClasePlantillaID INNER JOIN " +
                      " dbo.Cliente ON dbo.ClasePlantilla.ClienteID = dbo.Cliente.ClienteID INNER JOIN " +
                      " dbo.Clase ON dbo.ClasePlantilla.ClaseID = dbo.Clase.ClaseID " +
                      " WHERE  NOT ReservaID IN (Select ReservaID From ClaseAsistencia)  " + ViewState["sWhere"] + " " + ViewState["fecha"] + " " +
                      " clasefecha desc, dbo.Cliente.ClienteNombre asc, dbo.Clase.ClaseDescripcion asc";

        SqlDataAdapter dAdapter = new SqlDataAdapter(cmd2, cn);

        ds = new DataSet();
        dAdapter.Fill(ds);
        dt = ds.Tables[0];
        string[] TablaID = new string[1];
        TablaID[0]        = "UsuarioCedula";
        grid.DataKeyNames = TablaID;
        grid.DataSource   = dt;
        grid.DataBind();
        cn.Close();
        System.Text.StringBuilder sb  = new System.Text.StringBuilder();
        System.IO.StringWriter    sw  = new System.IO.StringWriter(sb);
        HtmlTextWriter            htw = new HtmlTextWriter(sw);
        Page page = new Page();

        System.Web.UI.HtmlControls.HtmlForm form = new System.Web.UI.HtmlControls.HtmlForm();
        GridView Grid = new GridView();

        grid.AllowPaging = false;
        grid.DataBind();
        grid.EnableViewState       = false;
        page.EnableEventValidation = false;
        page.DesignerInitialize();
        page.Controls.Add(form);
        form.Controls.Add(grid);
        page.RenderControl(htw);
        Response.Clear();
        Response.Buffer      = true;
        Response.ContentType = "application/vnd.ms-excel";
        Response.AddHeader("Content-Disposition", "attachment;filename=Usuarios_No_Asistieron_" + Hora + ".xls");
        Response.Charset         = "UTF-8";
        Response.ContentEncoding = System.Text.Encoding.Default;
        Response.Write(sb.ToString());
        Response.End();
    }
Example #44
0
 public string GetControlHtml(string controlLocation)
 {
     Page page = new Page();
     UserControl userControl = (UserControl)page.LoadControl(controlLocation);
     userControl.EnableViewState = false;
     HtmlForm form = new HtmlForm();
     form.Controls.Add(userControl);
     page.Controls.Add(form);
     StringWriter textWriter = new StringWriter();
     HttpContext.Current.Server.Execute(page, textWriter, false);
     return CleanHtml(textWriter.ToString());
 }
        protected void imgBtnExcel_Click(object sender, ImageClickEventArgs e)
        {
            StringBuilder sb = new StringBuilder();
            StringWriter sw = new StringWriter(sb);
            HtmlTextWriter htw = new HtmlTextWriter(sw);

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

            gdUsuario.EnableViewState = false;

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

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

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

            page.RenderControl(htw);

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

            //Response.Clear();

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

            //Response.Charset = "";

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

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

            //HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StringWriter);

            //gvDatosAdmin.AllowPaging = false;

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

            //Response.End();
        }
        // IXElementToControlMapper
        public bool TryGetControlFromXElement(XElement element, out Control control)
        {
            if (element.Name.Namespace != Namespaces.AspNetControls)
            {
                control = null;
                return false;
            }
            
            if (element.Name == _markerElementName)
            {
                control = _controls[element.Attribute("key").Value];
                return true;
            }

            if (element.Name == _formElementName)
            {
                control = new HtmlForm();

                element.CopyAttributes(control as HtmlForm, false);

                foreach (var child in element.Nodes())
                {
                    control.Controls.Add(child.AsAspNetControl(this));
                }

                return true;
            }

            if (element.Name == _placeholderElementName)
            {
                control = new PlaceHolder();

                XAttribute idAttribute = element.Attribute("id");
                if (idAttribute != null)
                {
                    control.ID = idAttribute.Value;
                }

                foreach (var child in element.Nodes())
                {
                    control.Controls.Add(child.AsAspNetControl(this));
                }

                return true;
            }

            throw new InvalidOperationException(string.Format("Unhandled ASP.NET tag '{0}'.", element.Name));
        }
Example #47
0
        private void WriteAttributes(HtmlTextWriter writer, HtmlForm form)
        {
            if (form.ID != null)
                writer.WriteAttribute("id", form.ClientID);
            writer.WriteAttribute("name", form.Name);
            writer.WriteAttribute("method", form.Method);

            foreach (string key in form.Attributes.Keys)
                writer.WriteAttribute(key, form.Attributes[key]);

            string url = Page.Request.QueryString["postback"];
            if (string.IsNullOrEmpty(url))
                writer.WriteAttribute("action", Page.Request.RawUrl);
            else
                writer.WriteAttribute("action", url);
        }
Example #48
0
        protected void btnExportErrors_Clicked(object sender, EventArgs e)
        {
            Response.Clear();
            Response.AddHeader("content-disposition", "attachment; filename=ImportErrorList.xls");
            Response.Charset = "";

            Response.ContentType = "application/vnd.xls";
            StringWriter stringWrite = new StringWriter();
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            HtmlForm newForm = new HtmlForm();
            this.Controls.Add(newForm);
            newForm.Controls.Add(gvErrorDetails);
            newForm.RenderControl(htmlWrite);
            Response.Write(stringWrite.ToString());
            Response.End();
            this.Dispose();
        }
Example #49
0
        public static string RetriveWebControl(String id)
        {
            Page pg = new Page();
            pg.EnableEventValidation = false;
            HtmlForm htmlForm = new HtmlForm();
            pg.Controls.Add(htmlForm);

            string path = @"\UserControls\maquina.ascx";
            maquina control = (maquina) pg.LoadControl(path);
            control.NomeMaquina = "Maquina "+id;
            control.IdMaquina = int.Parse(id);
            control.setaDados();
            htmlForm.Controls.Add(control);
            StringWriter output = new StringWriter();
            HttpContext.Current.Server.Execute(pg, output, true);
            return output.ToString();
        }
Example #50
0
        private string GetContactActivityPage(UserActivityView ctrlUserActivity, Contact contact, int messageCount)
        {
            var page = new Page();
            var form = new HtmlForm { EnableViewState = false };

            ctrlUserActivity = (UserActivityView)page.LoadControl(PathProvider.GetFileStaticRelativePath("SocialMedia/UserActivityView.ascx"));
            InitTwitter(ctrlUserActivity, contact);
            if (ctrlUserActivity.TwitterInformation.UserAccounts.Count == 0)
            {
                page.Controls.Add(new EmptyScreenControl
                {
                    ImgSrc = WebImageSupplier.GetAbsoluteWebPath("empty_screen_twitter.png", ProductEntryPoint.ID),
                    Header = CRMSocialMediaResource.EmptyContentTwitterAccountsHeader,
                    Describe = CRMSocialMediaResource.EmptyContentTwitterAccountsDescribe,
                    ButtonHTML = String.Format(@"<a class='link underline blue plus' href='javascript:void(0);'
                                                    onclick='ASC.CRM.SocialMedia.FindTwitterProfiles(jq(this),""{0}"", 1, 9);'>{1}</a>",
                                               contact is Company ? "company" : "people",
                                               CRMSocialMediaResource.LinkTwitterAccount)
                });

                return RenderPage(page);
            }

            ctrlUserActivity.MessageCount = messageCount;
            form.Controls.Add(ctrlUserActivity);
            page.Controls.Add(form);

            var executedPage = RenderPage(page);

            if (ctrlUserActivity.LoadedMessageCount == 0 && ctrlUserActivity.LastException == null)
            {
                page = new Page();

                //TODO
                page.Controls.Add(new EmptyScreenControl
                {

                    Header = CRMCommonResource.NoLoadedMessages,

                });
                executedPage = RenderPage(page);
            }

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

            }

            Page pg = new Page();

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

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

            //korzystanie z biblioteki websiteScreenshote

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

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

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

            Response.Redirect("~/ListaImprez.aspx");
        }
Example #52
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/html";

            //get name from GET or POST parameter
            string controlName = context.Server.UrlDecode(context.Request.Params["name"]);
            if (!string.IsNullOrEmpty(controlName))
            {
                try
                {
                    //define full virtual path
                    var fullPath = BASE_DIRECTORY + controlName;

                    //initialize a new page to host the control
                    Page page = new Page();
                    //disable event validation (this is a workaround to handle the "RegisterForEventValidation can only be called during Render()" exception)
                    page.EnableEventValidation = false;

                    //create the runat="server" from that must host asp.net controls
                    HtmlForm form = new HtmlForm();
                    form.Name = "form1";
                    page.Controls.Add(form);

                    //load the control and add it to the page's form
                    Control control = page.LoadControl(fullPath);
                    form.Controls.Add(control);

                    //call RenderControl method to get the generated HTML
                    string html = RenderControl(page);

                    //output it to the response stream
                    context.Response.Write(html);
                }
                catch (Exception ex)
                {
                    //output error messege to the response stream
                    context.Response.Write("Error: " + ex.Message);
                }

                //end the response
                context.Response.End();
            }
        }
Example #53
0
 protected override void OnInit(EventArgs e)
 {
     Controls.Add(new LiteralControl("\n<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.or" +
                 "g/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xh" +
                 "tml\" style=\"overflow: hidden\">\n"));
     HtmlHead head = new HtmlHead();
     Controls.Add(head);
     Controls.Add(new LiteralControl("\n<body>\n    "));
     HtmlForm form = new HtmlForm();
     Controls.Add(form);
     Controls.Add(new LiteralControl("\n</body>\n</html>\n"));
     string controlName = Request.Params["c"];
     if (!(String.IsNullOrEmpty(controlName)))
     {
         Control c = LoadControl(String.Format("~/Controls/Chart_{0}.ascx", controlName));
         form.Controls.Add(c);
     }
     base.OnInit(e);
     EnableViewState = false;
 }
Example #54
0
 protected void btnExcel_Click(object sender, EventArgs e)
 {
     HtmlForm form = new HtmlForm();
     Response.Clear();
     Response.Buffer = true;
     Response.AddHeader("content-disposition",
      "attachment;filename=GridViewExport.xls");
     Response.ContentType = "application/ms-excel";
     Response.Charset = "utf-8";
     Response.ContentEncoding = System.Text.Encoding.UTF8;
     HttpContext.Current.Response.Write("<font style='font-size:10.0pt; font-family:Times New Roman;'>");
     HttpContext.Current.Response.Write("<BR><BR><BR>");
     StringWriter sw = new StringWriter();
     HtmlTextWriter hw = new HtmlTextWriter(sw);
     form.Controls.Add(grDSSum);
     this.Controls.Add(form);
     form.RenderControl(hw);
     Response.Write(sw.ToString());
     Response.End();
 }
Example #55
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Session["try"] = new MailModel()
            {
                FirstName = "Pankaj",
                LastName = "dey"

            };
            Page page = new Page();
            var control = page.LoadControl("~/WebUserControl1.ascx");
            //create the runat="server" from that must host asp.net controls
            HtmlForm form = new HtmlForm();
            form.Name = "form1";

            page.Controls.Add(form);
            form.Controls.Add(control);
            //call RenderControl method to get the generated HTML
            string html = RenderControl(control);
            var renderControl = RenderControl(control);
        }
Example #56
0
        public static string UserControlLoader(string tipoCard)
        {
            Page page = new Page();
            Parlamentar vo_Parl = new Parlamentar();
            DataTable vdt_Card = vo_Parl.recuperaCards();
            LoadUserControlHelper componenteCard = (LoadUserControlHelper)page.LoadControl("~/Componentes/CardPolitico.ascx");
            (componenteCard.FindControl("lblNome") as Label).Text = vdt_Card.Rows[0]["nomeParlamentar"].ToString();
            (componenteCard.FindControl("lblGasto") as Label).Text = vdt_Card.Rows[0]["valorCard"].ToString();
            (componenteCard.FindControl("lblTipoCard") as Label).Text = vdt_Card.Rows[0]["descricaoCartao"].ToString();

            int casaDoParlamentar = Convert.ToInt32(vdt_Card.Rows[0]["casaParlamentar"]);
            string vs_UrlImagem = string.Empty;
            if (casaDoParlamentar == 1)
            {
                vs_UrlImagem = string.Format("http://www.senado.leg.br/senadores/img/fotos-oficiais/senador{0}.jpg", Convert.ToInt32(vdt_Card.Rows[0]["idParlamentar"]));
                (componenteCard.FindControl("lblCasaParlamentar") as Label).Text = " Senador(a)";
            }
            else
            {
                vs_UrlImagem = string.Format("http://www.camara.gov.br/internet/deputado/bandep/{0}.jpg", Convert.ToInt32(vdt_Card.Rows[0]["idParlamentar"]));
                (componenteCard.FindControl("lblCasaParlamentar") as Label).Text = " Deputado(a)";
            }
            string vs_cssCard = string.Empty;
            switch (tipoCard)
            {
                case "SENADOR_MAIOR_DIV": vs_cssCard = "header-bgDesempenhoRuim"; break;
                case "SENADOR_GASTADOR": vs_cssCard = "header-bgDesempenhoRuim"; break;
                case "DEPUTADOR_GASTADOR": vs_cssCard = "header-bgDesempenhoRuim"; break;
                case "DEPUTADOR_ECONOMICO": vs_cssCard = "header-bgDesempenhoBom"; break;
                case "SENADOR_MENOR_DIV": vs_cssCard = "header-bgDesempenhoBom"; break;
                case "SENADOR_ECONOMICO": vs_cssCard = "header-bgDesempenhoBom"; break;
            }
            (componenteCard.FindControl("imgGast") as Image).ImageUrl = vs_UrlImagem;
            componenteCard.EnableViewState = false;
            HtmlForm form = new HtmlForm();
            form.Controls.Add(componenteCard);
            page.Controls.Add(form);
            StringWriter textWriter = new StringWriter();
            HttpContext.Current.Server.Execute(page, textWriter, false);
            return textWriter.ToString();
        }
Example #57
0
        public SimpleForm(UserControl userControl)
        {
            this.userControl = userControl;
            this.form = FindForm(userControl);

            if (form == null)
            {
                throw new Exception("Form could not be found.");
            }

            if (form.ID == null)
            {
                throw new Exception("Form ID not set.  The form ID is needed as this is the name of the table which the data will be stored.");
            }

            //grab the form controls
            LoadControls();

            //create a schema
            formSchema = new FormSchema(form.ID);
        }
        protected void btXuatExcel_Click(object sender, EventArgs e)
        {
            HtmlForm form = new HtmlForm();
            string fileName = string.Format("BaoCao_SuCo_NgungGiam_{0}", DateTime.Now.ToString("MMyyyy_ddhhmm"));
            Response.ClearContent();
            Response.Buffer = true;
            Response.AddHeader("content-disposition", "attachment; filename=" + fileName + ".xls");
            Response.ContentType = "application/ms-excel";
            Response.Charset = string.Empty;
            Response.ContentEncoding = Encoding.Unicode;
            Response.BinaryWrite(Encoding.Unicode.GetPreamble());
            StringWriter strWri = new StringWriter();
            HtmlTextWriter txtWri = new HtmlTextWriter(strWri);

            Load_Data();
            form.Controls.Add(gvSuCo);
            this.Controls.Add(form);
            form.RenderControl(txtWri);
            Response.Write(strWri.ToString());
            Response.End();
        }
Example #59
0
        public static void Export(WebControl grid, Page page, string Filename, bool treatAsText, params int[] textColumns)
        {
            if ((treatAsText))
            {
                try
                {
                    foreach (GridViewRow row in ((GridView)grid).Rows)
                        if (textColumns == null || textColumns.Length == 0)
                        {
                            foreach (TableCell cell in row.Cells) cell.Attributes.Add("class", "text");
                        }
                        else
                        {
                            foreach (int i in textColumns) row.Cells[i].Attributes.Add("class", "text");
                        }
                }
                catch { }
            }

            HttpResponse response = HttpContext.Current.Response;
            response.Clear();
            response.Buffer = true;
            response.AddHeader("content-disposition", string.Concat("attachment;filename=", Filename));
            response.ContentEncoding = Encoding.Unicode;
            response.BinaryWrite(Encoding.Unicode.GetPreamble());

            response.Cache.SetCacheability(HttpCacheability.NoCache);
            response.ContentType = "application/vnd.ms-excel";
            page.EnableViewState = false;
            HtmlForm frm = new HtmlForm();
            page.Controls.Add(frm);
            frm.Controls.Add(grid);
            StringWriter stringWrite = new StringWriter();
            HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
            frm.RenderControl(htmlWrite);
            response.Write(@"<style>.text { mso-number-format:\@; }</style>");
            response.Write(stringWrite.ToString());
            response.Flush();
            response.End();
        }
Example #60
0
        protected bool Export()
        {
            try
            {
                string html = txtgantt_html.Value;

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

                HtmlGenericControl objTable = new HtmlGenericControl("table");

                objTable.InnerHtml = html;

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

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

                Response.Charset = "UTF-8";
                Response.ContentEncoding = Encoding.Default;
                Response.Write(objsb.ToString());
                Response.End();
                return true;
            }
            catch (Exception) { return false; }
        }