返回首页

您好

下面是我的代码打印的WebForm
我得到一个
错误
错误5"System.IO.StreamWriter'不包含一个构造函数在第3行的"0"参数
我要去的地方错了请纠正我,


public static void PrintWebControl(Control ctrl, string Script)

    {

        StreamWriter stringwriter = new StreamWriter();

        System.Web.UI.HtmlTextWriter htmlwriter = new System.Web.UI.HtmlTextWriter(stringwriter);

        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(htmlwriter);

        string strHTML = stringwriter.ToString();

        HttpContext.Current.Response.Clear();

        HttpContext.Current.Response.Write(strHTML);

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

        HttpContext.Current.Response.End();

 



    }

 



 


谢谢

回答

评论会员: 时间:2
A