Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
|
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 30th, 2004, 08:53 AM
Authorized User
 
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default showModalDialog()

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.

 
Old April 3rd, 2004, 04:02 AM
Registered User
 
Join Date: Mar 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

put IsPostBack check in the pag_load event of parent form as...

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

       If not IsPostBack Then
          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 If

 End Sub


 
Old April 4th, 2004, 08:27 PM
Authorized User
 
Join Date: Mar 2004
Posts: 47
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi tarunvars, thanks for your suggestion but it seems that this method does not work anyway...

 
Old June 6th, 2004, 04:08 PM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hope this helps:

In the <HEAD> tag of the child page place <base target="_self">.

This tells the form that it is the target of itself when it comes to various functions.

Next in the Page_Load event place the following:

Response.Cache.SetNoServerCaching();
Response.Cache.SetCacheability(System.Web.HttpCach eability.NoCache);
Response.Cache.SetNoStore();
Response.Cache.SetExpires(new DateTime(1900,01,01,00,00,00,00));

This will clear out the Cashe and allow the user to re-visit the child window again.








Similar Threads
Thread Thread Starter Forum Replies Last Post
showModalDialog Problem akhilesh_g Javascript 0 July 14th, 2008 06:43 AM
showModalDialog box dotnetuser ASP.NET 2.0 Basics 0 August 21st, 2007 11:46 PM
ShowModalDialog DarrenMelling Javascript How-To 7 February 17th, 2005 11:59 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.