WebForm_PostBackOptions 未定义
在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 未定义”。