Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1346
  • Last Modified:

Stop the refresh after window.showModalDialog returns.

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")
    }
    else
    {
        document.getElementById("txthTo").value=argAdrBk[0].toString(); // MemberIds
        document.getElementById("txtTo").value=argAdrBk[1].toString(); // CompanyName 4 display
    }
}
</script>

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;
 window.close();
}
</script>
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.

http://www.codeproject.com/aspnet/Modal_Dialog.asp 

for passing parameters and

http://www.mattkruse.com/javascript/optiontransfer/

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,

0
asifthakur
Asked:
asifthakur
1 Solution
 
TimCotteeCommented:
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
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now