WebForm_PostBackOptions 未定义

zengbingling 2010-07-16 01:46:36
在webconfig中加入了自定义模块<add name="StrConvHttpModule" type="ConvHttpModule.StrConvHttpModule, StrConvHttpModule"/>
StrConvHttpModule.cs文件如下:
public class StrConvHttpModule : IHttpModule
{
void context_BeginRequest(object sender, EventArgs e)
{
HttpApplication application = (HttpApplication)sender;
HttpContext context = application.Context;
context.Response.Filter = new StrConvFilterStream(context.Response.Filter);
}

void IHttpModule.Init(HttpApplication context)
{
context.BeginRequest += new EventHandler(context_BeginRequest);
}
}
public class StrConvFilterStream : Stream
{
private Stream _sink;
private long _position;
public StrConvFilterStream(Stream sink)
{this._sink = sink;}
public override bool CanRead
{get{return true;}
}
public VbStrConv Lang
{get;set;}

public override bool CanSeek
{get{return true;}
}
public override bool CanWrite
{get{return true;}
}
public override long Length
{get{return 0;}
}
public override long Position
{get{return this._position;}
set{this._position = value;}
}

public override long Seek(long offset, SeekOrigin direction)
{return this._sink.Seek(offset, direction);}

public override void SetLength(long length)
{this._sink.SetLength(length);}

public override void Close()
{this._sink.Close();}

public override void Flush()
{this._sink.Flush();}

public override int Read(byte[] buffer, int offset, int count)
{return this._sink.Read(buffer, offset, count);}

public override void Write(byte[] buffer, int offset, int count)
{
if (HttpContext.Current.Response.ContentType == "text/html")
{
Encoding e = Encoding.GetEncoding(HttpContext.Current.Response.Charset);
string s = e.GetString(buffer, offset, count);
s = Strings.StrConv(s, Lang, CultureInfo.CurrentCulture.LCID);
this._sink.Write(e.GetBytes(s), 0, e.GetByteCount(s));
}
else
{
this._sink.Write(buffer, offset, count);
}
}
}

问题:
所有页面只要有用微软自带的验证控件如:requiredfieldvalidator,在单击按钮回发时都会出现脚本错误:“WebForm_PostBackOptions 未定义”。
...全文
666 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
tvxq_yunkjj 2011-05-26
  • 打赏
  • 举报
回复
我也遇到这样的问题,请高手指教
zengbingling 2010-07-16
  • 打赏
  • 举报
回复
高手请进
zengbingling 2010-07-16
  • 打赏
  • 举报
回复
不是一样的。把 context.Response.Filter = new StrConvFilterStream(context.Response.Filter);注释就对的。还有就是把页面的验证控件去掉也没有问题
。估计是验证控件response时的问题
BaoShiqiang 2010-07-16
  • 打赏
  • 举报
回复
照着做就应该行了

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

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