I'm practising using showModalDialog() but there is a problem occur during the execution. when i close or submit a value back to parent.aspx from child.aspx, the application will pop up another child.aspx in the same time the value transfer back to parent.aspx. the sample codes are as below
===========
parent.aspx
===========
<%@ Page AutoEventWireup="false" Src="parent.aspx.
vb" Inherits="parent"%>
<form runat="server">
<asp:textbox runat="server" id="submitText"/>
<asp:button runat="server" id="button1" Text="Submit"/>
</form>
==============
parent.aspx.
vb
==============
Public Class parent
Inherits System.Web.UI.Page
Protected WithEvents button1 As System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
button1.Attributes.Add("onclick", "var strReturn; strReturn=window.showModalDialog"& _
"('child.aspx','','status:no;dialogWidth:370px;dia logHeight:220px;"& _
"dialogHide:true;help:no;scroll:yes;');if (strReturn != null) document.getElementById('SubmitText')."& _
"value=strReturn;")
End Sub
End Class
==========
child.aspx
==========
<%@ Page Language="
vb" AutoEventWireup="false" Src="child.aspx.
vb" Inherits="child"%>
<form runat="server">
<asp:textbox id="returnText" runat="server"/>
<asp:button id="Submit" runat="server" Text="Submit"/>
<asp:button id="btnCancel" runat="server" Text="Cancel"/>
</form>
=============
child.aspx.
vb
=============
Public Class child
Inherits System.Web.UI.Page
Protected WithEvents submit, btnCancel As System.Web.UI.WebControls.Button
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
submit.Attributes.Add("onclick", "window.returnValue = "& _
"document.getElementById('returnText').value; window.close();")
btnCancel.Attributes.Add("onclick", "window.close();")
End Sub
End Class
===============================================
Can anybody tells me why this happen? I keep and keep searching for the problem but failed. any help will be appreciated.