The client side PostBack script of ASP. NET 1.x is as follows:
<! --
Function _ dopostback (eventtarget, eventargument ){
VaR theform;
If (window. Navigator. appname. tolowercase (). indexof ("Netscape")>-1 ){
Theform = Document. Forms ["form1"];
}
Else {
Theform = Document. form1;
}
Theform. _ eventtarget. value = eventtarget. Split ("$"). Join (":");
Theform. _ eventargument. value = eventargument;
Theform. Submit ();
}
// -->
It
It uses form. Submit () to submit. In this case, the form. onsubmit event will not be triggered, so some clients may
The side validation script is bypassed. In ASP. NET 2.0, this problem is fixed. For ASP. NET
1. X. As far as I know, SP1 does not solve this problem either. We can use the followingCodeSolve this problem:
String mydopostback = @"
<Script language = "" JavaScript "">
<! --
Function _ mydopostback (eventtarget, eventargument ){
VaR theform;
If (window. Navigator. appname. tolowercase (). indexof ("" Netscape "")>-1 ){
Theform = Document. Forms ["form1" "];
}
Else {
Theform = Document. form1;
}
Theform. _ eventtarget. value = eventtarget. Split ("" $ ""). Join ("":"");
Theform. _ eventargument. value = eventargument;
If (typeof (theform. onsubmit) = "" function "") & theform. onsubmit ()! = False ){
Theform. Submit ();
}
}
_ Dopostback = _ mydopostback
// -->
</SCRIPT> ";
Registerstartupscript ("mydopostback", mydopostback );
Trackback: http://tb.blog.csdn.net/TrackBack.aspx? Postid = 194208