JS嵌套问题(大哥们帮我呀!)
a.aspxdocument.writeln(\"    <form id='form2' method='post' action='' enctype='multipart/form-data'>\");
document.writeln(\"            <td style='width:50% ;'><input type='text' id='p0' name='p0' style='width: 217px'></td>\");
document.writeln(\"            <input type='submit'  ID='Button3' value='确定' />\");
document.writeln(\"    </form>\");
a.aspx.cs
p0 = Request.Form["p0"] != null ? Request.Form["p0"].ToString() : "";b.aspx
<script src="a.aspx" type="text/javascript"></script>
为什么得不到值呀!

a.aspx改为
<script>
document.writeln(\"    <form id='form2' method='post' action='' enctype='multipart/form-data'>\");
document.writeln(\"            <td style='width:50% ;'><input type='text' id='p0' name='p0' style='width: 217px'></td>\");
document.writeln(\"            <input type='submit'  ID='Button3' value='确定' />\");
document.writeln(\"    </form>\");
</script>就可以得到值
为啥嵌套就不行了呢?
望大哥们帮小弟一把~  小弟先谢了

解决方案 »

  1.   

    把文件名存为后缀为.js就可以了,不要.aspx
      

  2.   

    b.aspx 中的 <script src="a.aspx" type="text/javascript"></script>
    指的是把a.aspx中的代码读入JS解释器中执行.那就是说 a.aspx 必须是纯JS代码,如果不是纯JS代码,那JS解释器就会不识别,报错
    然而 <script> 标签是HTML标签,不是JS代码,
    故 a.aspx 中的 <script> 标签将不被识别,而报错.