读书人

windows.showModalDialog窗体中点击按

发布时间: 2012-01-03 22:16:06 作者: rapoo

windows.showModalDialog窗体中点击按钮弹出两次提示窗口错误!急
各位好:遇到一个棘手的问题,在打开的模式窗体中,点击服务器按钮控件,在按钮事件中写
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "alert( '123 '); ",true);弹出两次提示窗体!

不明白为何弹出两次,具体代码如下。

页面1:调用模式窗体的父窗体
<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "TestPage.aspx.cs " Inherits= "htManage_TestPage "

%>

<head runat= "server ">
<title> 1 </title>
<script language= "javascript ">
function showErrMsg()
{
window.showModalDialog

( "TestPageFrame.aspx ", " ", "center=yes;dialogHeight=20;dialogWidth=20;resizable=yes;status=yes;scroll=yes;

help=no ");
}
</script>
</head>
<body>
<form id= "form1 " method= "post " runat= "server ">
<div>
<input onclick= "return showErrMsg(); " type= "button " value= "保 存 " id= "button2 " name= "btnSave " />
</form>
</body>
</html>

页面2:模式窗体的加载窗体

<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "TestPageFrame.aspx.cs "

Inherits= "htManage_TestPageFrame " %>

<head >
<title> 2 </title>
<base target= "_self "> </base>
</head>

<frameset rows= "0,* ">
<frame src= "about:blank ">
<frame src= "TestPage2.aspx ">
</frameset>
</html>

页面3: 模式窗体

<%@ Page Language= "C# " AutoEventWireup= "true " CodeFile= "Testpage2.aspx.cs " Inherits= "htManage_Testpage2 "

%>

<head>
<title> 3 </title>
<base target= "_self "> </base>
<script language= "javascript ">
function showErrMsg()
{
window.showModalDialog

( "TestPage3.aspx ", " ", "center=yes;dialogHeight=20;dialogWidth=20;resizable=yes;status=yes;scroll=yes;help

=no ");
}
</script>
</head>


<body>
<form id= "form1 " runat= "server " method= "post ">
<div>
<asp:Button ID= "Button1 " runat= "server " OnClick= "Button1_Click " Text= "Button " />
<input type= "button " value= "关闭 " onclick= "window.close() ">
</div>
</form>
</body>
</html>


页面4:模式窗体的后台代码
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class htManage_Testpage2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "alert( '123 '); ",true);
}
}

在这里先谢过各位达人,不吝赐教。




[解决办法]
有点乱...
[解决办法]
代码好像有些贴错了
[解决办法]
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "alert( '123 '); ",true);
这句改成
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "123 ",true);试下
[解决办法]
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "alert( '123 '); ",true);
这句改成
ClientScript.RegisterStartupScript(this.GetType(), "confirm ", "123 ",true);试下

[解决办法]
http://www.cshap.cn/
或许能找到你感兴趣的问题
[解决办法]
更正:
ClientScript.RegisterStartupScript(this.GetType(), "alert ", " <script> alert( '123 ') </script> ",true)
[解决办法]
我上面回答不对,
刚才你你代码试下,就出来一次呀,html哪里出错
[解决办法]

更正:
ClientScript.RegisterStartupScript(this.GetType(), "alert ", " <script> alert( '123 ') </script> ",true)
============================================
0次
睡觉
[解决办法]
4。防止打开新窗口(如提交表单):
<base target= "_self ">


[解决办法]
up~~~~~~~

[解决办法]
是否应该用IsStartupScriptRegistered来避免重复注册脚本.
[解决办法]
ClientScript.RegisterStartupScript(this.GetType(), "submitOk ", "alert( '123 '); ",true);
===============================================
Page.ClientScript.RegisterStartupScript(this.GetType(), " ", " <script> alert( '123 ') </script> ");

读书人网 >asp.net

热点推荐