print from ascx code behind - no suitable method found to override

liveblue

New Member
I have a webpart that I am trying and I am trying to print a gridview. I have a ascx.cs with one public class for code behind. I created a method to print the grid here : \[code\] 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(); }\[/code\]Then I used this snippet of code to check for the form tag :\[code\] public override void VerifyRenderingInServerForm(Control control) { return; /*Verifies that the control is rendered */ }\[/code\]Then I get " no suitable method found to override. " from the debugger. Is there a way to do this without creating a partial class just for this one button event?
 
Back
Top