从后面的ascx代码打印 - 找不到合适的方法来覆盖

时间:2012-12-27 23:57:53

标签: c# asp.net user-controls

我有一个我正在尝试的webpart,我正在尝试打印gridview。我有一个ascx.cs,后面有一个公共类代码。我在这里创建了一个打印网格的方法:

        protected void print_grid_2_Click(object sender, EventArgs e)
        {
            fill_grid_search();
            grd_search.AllowPaging = false;
            grd_search.DataBind();
            StringWriter sw = new StringWriter();
            HtmlTextWriter hw = new HtmlTextWriter(sw);
            grd_search.RenderControl(hw);
            string gridHTML = sw.ToString().Replace("\"", "'")
                .Replace(System.Environment.NewLine, "");
            StringBuilder sb = new StringBuilder();
            sb.Append("<script type = 'text/javascript'>");
            sb.Append("window.onload = new function(){");
            sb.Append("var printWin = window.open('', '', 'left=0");
            sb.Append(",top=0,width=1000,height=600,status=0');");
            sb.Append("printWin.document.write(\"");
            sb.Append(gridHTML);
            sb.Append("\");");
            sb.Append("printWin.document.close();");
            sb.Append("printWin.focus();");
            sb.Append("printWin.print();");
            sb.Append("printWin.close();};");
            sb.Append("</script>");
            Page.ClientScript.RegisterStartupScript(this.GetType(), "GridPrint", sb.ToString());
            fill_grid_search();
            grd_search.AllowPaging = true;

            grd_search.DataBind();
        }

然后我使用这段代码来检查表单标记:

 public override void VerifyRenderingInServerForm(Control control)
        {
            return; /*Verifies that the control is rendered */
        }

然后我从调试器中得到“没有找到合适的方法来覆盖。”。有没有办法在没有为这个按钮事件创建部分类的情况下执行此操作?

0 个答案:

没有答案