Stop the refresh after window.showModalDialog returns.

Posted on 2006-06-06
Last Modified: 2008-01-09
i have an inbox where i have an imagebutton that uses a javascipt to popup an addressbook just like the one in hotmail. users are selected and passed to parent window using javascript. here is a snap of the code i am using.

<script language="javascript">
function OpenChild()
    var ParmtxthTo = document.getElementById("txthTo").value;            // hidden
    var ParmtxtTo = document.getElementById("txtTo").value;
    var ParmtxthFrom = document.getElementById("txthFrom").value;   // hidden
    var argAdrBk = new Array(ParmtxthTo, ParmtxtTo, ParmtxthFrom);
    var dlgSettings = "center:yes;dialogHeight:300px;dialogWidth=675px;dialogHeight=230px"

    var argAdrBk;
    var argAdrBk = window.showModalDialog("Module/AddressBook.aspx", argAdrBk, dlgSettings);
    if (argAdrBk == null)
        window.alert("Nothing returned from child. No changes made to input boxes")
        document.getElementById("txthTo").value=argAdrBk[0].toString(); // MemberIds
        document.getElementById("txtTo").value=argAdrBk[1].toString(); // CompanyName 4 display

The user selects a value in a listbox.. called list2 this is how i return the values..

<script language="javascript">
function Done()
 var ParmtxthTo = document.getElementById("newRight").value;
 var ParmtxtTo = document.getElementById("newRightCorp").value;
 var ParmtxtFrom = "AdrBk";
 var retArgs = new Array(ParmtxthTo, ParmtxtTo, ParmtxtFrom);

 window.returnValue = retArgs;
The Problem:

when ever the user is done with the address book, and presses the close button (where this Done(); function is called), the parameters are passed to the parent window and the page is refeshed.. which causes other hidden HTMLtable controls to be displayed on the same page.

how can i stop that.

I developed a combination of the following two articles.

for passing parameters and

for the addressbook.. except that i converted all controls on addressbook to html server controls. and on page_load get them populated.

I am using ASP.Net 1.1 with VB code and my parent window contains a user control from where this popup window is called on the click event of an imagebutton...

Thanks in advance,

Question by:asifthakur
    1 Comment
    LVL 44

    Accepted Solution

    Hi asifthakur,

    Make sure that you include return false; in the onclick event of the imagebutton. Otherwise you will postback the page which is what I think you are describing.

    ImageButton.Attributes.Add("OnClick","DoMyPopup();return false;")

    For example.

    Tim Cottee

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
    Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now