Ajax加载下在进度,消息: Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的

useruse 2010-05-20 01:09:44

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Web.Test" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="IE=EmulateIE7" http-equiv="X-UA-Compatible">
<title>Untitled Page</title>
</head>
<body>
<form id="MyForm" runat="server"><div id="Main">

<div id="NowMenu">
<div id="NowButton">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Loading" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Loading" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
<asp:AsyncPostBackTrigger ControlID="Button2" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</div>
<asp:UpdateProgress ID="UpdateProgress2" runat="server" AssociatedUpdatePanelID="UpdatePanel1">
<ProgressTemplate>
<div id="loader_container">
<div id="loader">
<div style="text-align:center;"><img alt="loading" style=" vertical-align:middle; margin-right:8px;" src="/Template/Image/loading.gif" />数据载入中,请稍后……</div>
<div id="loader_bg"><div id="progress"></div></div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>

</div>
</form>
</body>
</html>




protected void Button1_Click(object sender, EventArgs e)
{
System.Threading.Thread.Sleep(3000);
}

public void Button2_Click(object sender, EventArgs e)
{
string Sql = " Where [StatUs]=0 And [State] !='D' And [Position] = 'C' ";
GetContent(Sql, DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));
}

/// <summary>
/// 下载文件,文件名重写
/// </summary>
/// <param name="FileName">文件名</param>
/// <param name="FileContent">文件内容</param>
/// <returns>无</returns>
public static void DownloadExport(string FileName, string FileContent)
{
byte[] txtcontent = Encoding.Default.GetBytes(FileContent);
try
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Charset = "utf-8";
HttpContext.Current.Response.Buffer = false;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(System.Text.Encoding.UTF8.GetBytes(FileName)));
HttpContext.Current.Response.AppendHeader("Content-Length", txtcontent.Length.ToString());
HttpContext.Current.Response.ContentType = "application/octet-stream";
HttpContext.Current.Response.BinaryWrite(txtcontent);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.Close();
HttpContext.Current.Response.End();
}
catch (Exception ex)
{
throw (ex);
}
finally
{
txtcontent.Clone();
}
}



点击按钮会出现加载数据的层,可是结束后报错:
网页错误详细信息

消息: Sys.WebForms.PageRequestManagerParserErrorException: 无法分析从服务器收到的消息。之所以出现此错误,常见的原因是: 在通过调用 Response.Write() 修改响应时,将启用响应筛选器、HttpModule 或服务器跟踪。
详细信息: 分析附近的“====================”时出错。
行: 4723
字符: 21
代码: 0
URI: http://172.18.254.125:808/ScriptResource.axd?d=

请高手指点如何解决!!
...全文
1042 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
li2012kui 2011-09-15
  • 打赏
  • 举报
回复
<Triggers>
<asp:PostBackTrigger ControlID="Button1" />
<asp:PostBackTrigger ControlID="Button2" />
</Triggers>
useruse 2010-05-26
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 gongxy_0202 的回复:]
http://hi.baidu.com/a_magic/blog/item/2d9c2811fe90f9cca7ef3fa8.html
看看这里
[/Quote]

内容看了,网站使用了網站有使用 HTTP modules,可是出现这样问题如何解决呢?
useruse 2010-05-26
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 showbo 的回复:]
你的Page_Load呢??

在Page_Load中判断是否为回调


C# code
protected void Page_Load(object sender,EventArgs e)
{
if(!Page.IsPostBack){
//....
}
}
[/Quote]


加了的
gxy111 2010-05-25
  • 打赏
  • 举报
回复
http://hi.baidu.com/a_magic/blog/item/2d9c2811fe90f9cca7ef3fa8.html
看看这里
Go 旅城通票 2010-05-24
  • 打赏
  • 举报
回复
你的Page_Load呢??

在Page_Load中判断是否为回调

protected void Page_Load(object sender,EventArgs e)
{
if(!Page.IsPostBack){
//....
}
}
useruse 2010-05-24
  • 打赏
  • 举报
回复
楼上说的也不行哦
h475410885 2010-05-20
  • 打赏
  • 举报
回复
byte[] txtcontent = Encoding.Default.GetBytes(FileContent);
你这个是用字节读取到输入的吧,
我建议你用流来得到数据然后在转换过来,

文件下载-以字节流的形式下载


string id=Request.QueryString["id"];
string dbname;
string file;
string strSql="select Softname from Upload where Upload_ID="+id;

OleDbConnection conn=new OleDbConnection();
dbname=Server.MapPath"Data/cz.mdb");
conn.ConnectionString="PROVIDER=Microsoft.Jet.OLEDB.4.0;DATA Source="+dbname;

conn.Open();
OleDbDataAdapter ada=new OleDbDataAdapter(strSql,conn);
DataSet ds=new DataSet();
ada.Fill(ds);
conn.Close();

file=ds.Tables[0].Rows[0][0].ToString();
FileInfo thisfile=new FileInfo(file);
string sFileName=thisfile.Name;
string filePath=Server.MapPath("DownFiles/")+file;
thisfile.Close();

Response.AppendHeader("Content-Disposition","attachment;filename="+HttpUtility.UrlEncode(sFileName,System.Text.Encoding.Default));//sFileName文件名
Response.WriteFile(filePath);//filePath文件路径
Response.End();

useruse 2010-05-20
  • 打赏
  • 举报
回复
请高手指点如何解决!!

52,797

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧