asp.net 1.1 版本里有一个BUG都知道
如果你把Form放在ascx里面而且有__doPostBack调用的话肯定会是下面这样地:
<!--
function __dopostback(eventtarget, eventargument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["_ctl0:Form1"];
}
else {
theform = document._ctl0:Form1; // 这玩意一眼都看出有错!!
}
theform.__eventtarget.value = eventtarget.split("$").join(":");
theform.__eventargument.value = eventargument;
theform.submit();
}
// -->
有时候做项目,用户环境就这样,你不可能去把客户的系统重新安装过!!....会死人的!!
利用javascript 里面的"函数重载", 简单:
在<form ....>的下面手动再添加一个__doPostBack 函数:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["_ctl0:Form1"];
}
else {
theform = document._ctl0_Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
// alert("你自己的doPostBack");
}
// -->
</script>
安逸, 生成 HTML里面就会出现两上__doPostBack,而到的就是你的!
本文介绍了一个ASP.NET 1.1版本中的__doPostBack调用BUG,并提供了一种通过重定义JavaScript函数来解决该问题的方法。
372

被折叠的 条评论
为什么被折叠?



