ASP.NET中的FORM表单产生的JS错误问题,如何解决?
在aspx页面中我直接调用的用户控件,比如:
<mybbs:forumhome id="forumhome1" runat="server" />
然后在用户控件forumhome中是完整的页面内容,比如:
<html>
<title>mybbs</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:LinkButton id="LinkButton1" runat="server">LinkButton</asp:LinkButton>
</form>
</body>
</html>
然而访问页面出现js错误。调试发现错误在于:
<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("netscape") > -1) {
theform = document.forms["forumhome:Form1"];
}
else {
theform = document.forumhome:Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>
这个js函数,而且就是其中的
theform = document.forms["forumhome:Form1"];
和
theform = document.forumhome:Form1;
这两个语句出错。其实可能问题就在于forumhome:Form1在js中是错误的表达式。
产生的HTML代码中的FORM部分为
<form name="forumhome:Form1" method="post" action="index.aspx" id="forumhome_Form1">
请问这个问题该如何解决,谢谢!