divv2.innerHTML = http_request.responseText;执行到这句就提示..未知的运行时错误..
  
Default.aspx页面代码
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Src="userTreeView.ascx" TagName="userTreeView" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>-ShunZiRan.Com--南昌市顺自然文化传播有限公司-</title>
    <link href="index.css" rel="Stylesheet" type="text/css"/>
    <script type="text/javascript">
        var http_request = false;
    
    function send_request(url) {//初始化、指定处理函数、发送请求的函数
    
    http_request = false;
    //开始初始化XMLHttpRequest对象
    if(window.XMLHttpRequest) { //Mozilla 浏览器
    http_request = new XMLHttpRequest();
    if (http_request.overrideMimeType) {//设置MiME类别
    
    http_request.overrideMimeType('text/xml');
    }
    }
    else if (window.ActiveXObject) { // IE浏览器
    try {
    http_request = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    http_request = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e) {}
    }
    }
    if (!http_request) { // 异常,创建对象实例失败
    window.alert("不能创建XMLHttpRequest对象实例.");
    return false;
    }
    http_request.open("GET", url, false);
    http_request.send(null);
    //http_request.onreadystatechange = processRequest;
    // 确定发送请求的方式和URL以及是否同步执行下段代码
   
    if (http_request.readyState==4 || http_request.readyState=='complete' ){
    var divv2 = document.getElementById("divv2"); 
    divv2.innerHTML = http_request.responseText;
    }
    }
    </script>
</head>
<body leftMargin=0 topMargin=0 marginheight="0" marginwidth="0"  onload="send_request('HTMLPage.htm')">
 <form id="form1" runat="server">
<table style="width: 913px; height: 76px">
            <tr>
                <td colspan="3"><!--#include file="top.htm"--> 
                </td>
            </tr>
            <tr valign="Top">
                <td style="width: 3px">
                </td> 
                <td style="width: 216px">
    <uc1:userTreeView ID="UserTreeView1" runat="server" />
                </td>
                <td><div id="divv2">数据载入中...</div>
                </td>
            </tr>
            <tr>
                <td style="width: 3px">
                </td>
                <td style="width: 216px">
                </td>
                <td>
                </td>
            </tr>
        </table>
    </form>
</body>
</html>
被请求的login.aspx页面
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Login.aspx.cs" Inherits="Login"  ValidateRequest="false" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>无标题页</title>
</head>
<body>
    <form  runat="server">
    <div>
        &nbsp;&nbsp;
        <table style="width: 494px; height: 314px">
            <tr>
                <td style="width: 185px">
                    用户名</td>
                <td>
        <asp:TextBox ID="txtUser" runat="server"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="用户名不能为空" ControlToValidate="txtUser" Display="None"></asp:RequiredFieldValidator></td>
                <td>
        <asp:Button ID="btnLogin" runat="server" Text="登陆" OnClick="btnLogin_Click" /></td>
            </tr>
            <tr>
                <td style="width: 185px">
                    密码</td>
                <td>
        <asp:TextBox ID="txtPass" runat="server" TextMode="Password" Width="150px"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="密码不能为空" ControlToValidate="txtPass" Display="None"></asp:RequiredFieldValidator></td>
                <td>
                </td>
            </tr>
            <tr>
                <td style="width: 185px">
                </td>
                <td>
                    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True"
                        ShowSummary="False" />
                </td>
                <td>
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>
当我请求login.aspx页面的时候就有错误。但我换了页面句没有问题。不会有问题。而且正常显示。 .但是我的login.aspx页面内容没问题。可是我把Default.aspx再改一下.请求login.aspx页面就不会有问题。
把<div id="divv2">数据载入中...</div>放在form1标签外面就不会有问题。而且的到的值也正常,经过我查看。发现原来是login.aspx里面有个form和Defualt.aspx里面的form冲突。但是login.aspx里面的form1我又不可以去掉。去掉就爆错的.

解决方案 »

  1.   

    form不能嵌套的,你执行完divv2.innerHTML = http_request.responseText后 form嵌套了,当然报错了,你的default页面有个用户控件,所以不能去掉form,我觉得可以把form改成并列关系
    ,把default里面form的位置套到自定义控件外,但是不包含div。
       <td style="width: 216px">
       <form id="formx">
        <uc1:userTreeView ID="UserTreeView1" runat="server" />
       </form>
                    </td>
                    <td><div id="divv2">数据载入中...</div>
                    </td>
      

  2.   

    lindping(罗将神)就是说的那样。。   可是还有别的更好的办法吗
      

  3.   

    最好的办法我认为就是把 http_request.responseText中的from去掉