[此贴子已经被作者于2007-4-17 13:35:46编辑过]
[QUOTE]Response函数
自动弹出
楼主不是想用Response.Write什么的东西吧,在类里面好像不能用这种东西吧,那个是接收用户请求的类,应该只能在页面中才能用的[/QUOTE]
对我要问的就是这个我把代码发上去,我是看书上有个用Word打印的例子,而我的项目里有很多要用到打印的,所以我想建个类,但是这个代码好象有点问题
public class Comm1
{
public SqlConnection myConnection = new SqlConnection(ConfigurationManager.ConnectionStrings["labConnectionString"].ConnectionString);
public Comm1()
{
}
public void ENQ(string str)
{
SqlCommand myCommand = new SqlCommand(str, myConnection);
myCommand.Connection.Open();
myCommand.ExecuteNonQuery();
myConnection.Close();
return;
}
private void Export(string Filetype, string FileName)
{
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(FileName, Encoding.UTF8).ToString());
Response.ContentType = FileType;
this.EnableViewState = false;
StringWriter tw = new StringWriter();//这个也没有
HtmlTextWriter hw = new HtmlTextWriter(tw);
DataGrid1.RenderControl(hw);
Response.Write(tw.ToString);
Response.Write(hw.ToString());
Response.End();
}
}
[此贴子已经被作者于2007-4-18 10:30:36编辑过]