日期:2014-05-18  浏览次数:20508 次

为什么程序还往下执行??????????
为什么我在程序里写了这句,这句下面的程序还是执行了。怎么让下面的程序不执行呢?


Response.Write("<script>alert('stop');window.location='home.aspx'</script>");

------解决方案--------------------
Response.Write(" <script> alert('stop');window.location='home.aspx' </script> ");
Response.End;
------解决方案--------------------
Response.Write(" <script> alert('stop');window.location='home.aspx' </script> ");
只是输出一个字符串"<script>alert('stop');window.location='home.aspx'</script>"而已,当然不会停止
------解决方案--------------------
设断点调试一下就知道了
------解决方案--------------------
while (tr.Read()) 

if(判断条件)

Response.Write(" <script> alert('stop');window.location='home.aspx' </script> "); 



。。。。。。。。。。。。。。。//这里还有代码。这些代码怎么还是执行了呢????我不想他们执行了


你的思路有问题,因为执行Response.Write时,并没有把代码发送到页面,所以当前不会停下。你先看一下aspx的页面生存周期吧。
------解决方案--------------------
为什么会不执行呢?
程序走出WHILE就到了下面的代码段,没错啊
你应该去判断你的 
Response.Write(" <script> alert('stop');window.location='home.aspx' </script> "); 
这段语句是否执行了如果执行了就STOP否则GO。
------解决方案--------------------
Response.End;
请分清楚前后台的区别
------解决方案--------------------
Response.End();加上
------解决方案--------------------
如果您问题已经得解决,请您及时结帖给分,以感谢帮助您的朋友。 

结帖方法:点击版面右上方或右下方 <管理> ,进入页面后就可以输入密码,分别给分,结帖。 
或参考:http://www.csdn.net/help/over.asp
------解决方案--------------------
Response.Write(" <script> alert('stop');window.location='home.aspx' </script> ");
==============
Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<<script> alert('stop');window.location='home.aspx' </script>");