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

F5刷新意外自动打开新页
当前页1.aspx
执行
protected   void   Button4_Click(object   sender,   EventArgs   e)
        {
Response.Write( " <script> window.open( '2.aspx?id= "   +   Convert.ToInt32(Session[ "ID "])   +   " ') </script> ");
        }
打开第二个窗口,2.aspx关闭以后
F5刷新1.aspx,会自动弹出刚才的Button4按钮事件,以往想实现这样,还需要去特殊处理,现在不知道为什么会有这种情况。怎样解决

------解决方案--------------------
不要用Response.write
给Button后台加个事件不就行了.
btn.Attributes.Add( "onclick ", "要执行的代码 ")
------解决方案--------------------
你可以用label的方式写, <script> window.open( '2.aspx?id= " + Convert.ToInt32(Session[ "ID "]) + " ') </script> . 在pageload 中写 label.text= " "; 就可以了
------解决方案--------------------
顶楼上的,因为你提交过表单,因为刷新意味着再次提交