首页 新闻 赞助 找找看

C#注册脚本事件后,脚本不执行

0
悬赏园豆:10 [已解决问题] 解决于 2013-03-06 14:03
public void educeDoc(string FileName, string FileType, string s)
        {
            //清除反冲区的内容
            Response.Clear();
            //设置输出流的http字符集
            //Response.Charset = "gb2312";
            //将一个HTTP头添加到输出流
            Response.AddHeader("content-disposition", "attachment;filename=" + System.Web.HttpContext.Current.Server.UrlEncode(FileName));
            //设置输出的HTTP MIME类型
            Response.ContentType = FileType;
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            sb.Append(@"<html xmlns:v='urn:schemas-microsoft-com:vml' xmlns:o='urn:schemas-microsoft-com:office:office' xmlns:w='urn:schemas-microsoft-com:office:word' xmlns:m='http://schemas.microsoft.com/office/2004/12/omml' xmlns='http://www.w3.org/TR/REC-html40'><head></head><body lang=ZH-CN>");
            sb.Append(@"<style type='text/css'>");
            sb.Append(@"div.print_table_title2 { text-align:center; width:100%; font-size:x-large; font-weight:bold; height:45px;line-height: 45px; font-family:@黑体; margin-top:10px;}");
            sb.Append(@".ao_table{border:1px solid #000;}");
            sb.Append(@".ao_table td{border:1px solid #000;}");

            sb.Append(@"div.print_table_title { text-align:center; width:100%; font-size:xx-large; font-weight:bold; height:45pt;line-height: 45pt; font-family:@黑体;}");
            sb.Append(@"#divTable .ao_table table{border:none;}");
            sb.Append(@"#divTable .ao_table table tr td{border:none;}");
            sb.Append(@"</style>");
            sb.Append(s);
            sb.Append("<body></html>");
            //把字符数组写入HTTP响应输出流
            Response.Write(sb.ToString());
            Page.ClientScript.RegisterStartupScript(Page.GetType(), "ReloadLocationPage", "refreshPage();", true);
            //发送完,关闭
            Response.End();

        }
refreshPage()是个页面刷新方法
hardy_Wang的主页 hardy_Wang | 初学一级 | 园豆:17
提问于:2012-12-11 10:49
< >
分享
最佳答案
0

你把 Append 的内容直接存成 htm,然后在浏览器中浏览,或者通过 IE 的开发人员工具在客户端调试下你这个页面,先确定你的页面代码是正确的。

收获园豆:10
Launcher | 高人七级 |园豆:45045 | 2012-12-11 11:17

输出的html是直接生成一个word表单的,和repsonse应该没什么关系,我是实现本页面刷新就好了

hardy_Wang | 园豆:17 (初学一级) | 2012-12-11 11:20

@未找到对象: 刷新的动作由浏览器发起的,所以请你在IE中调试你这个页面,看看生成的html页面是否具有正确的脚本,以及脚本是否正确执行。

你得明白浏览器解析HTML的原理,你在服务器端写的任何代码到了浏览器中就是HTML+JS,浏览器通过解析HTML+JS来决定页面的外观和行为。

http://www.cnblogs.com/chenmo0202032220/archive/2009/03/26/1422106.html

Launcher | 园豆:45045 (高人七级) | 2012-12-11 11:32
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册