Pop up window close and redirect to the main page

I have a pop up window which opens from my main page and some parameters are passed to this page through querystring
cmdAddPopup.Attributes.Add("onclick", "javascript:OpenNewPopUp(" & record_id & ", " & country.SelectedIndex & ");return false;")


I want the pop window to close when the user clicks the save button rather than displayign the updated information and forcing it to close from dialog box.  It should also redirect to the calling page and reload the main page again I also want to pass back the record number in response.redirect.

Currently my pop up window displays the updated data and doesnot close unless forced to
Tried adding the following lines  after savedata is called but it doesnot work
 
Protected Sub cmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSave.Click
       
            SaveData()    
            cmdSave.Attributes("onclick") = "javascript:window.close();return false;"
            cmdSave.Attributes.Add("onclick", "javascript:return CloseAndRedirect();")
        Else
            myMasterpage.StatusMessage = strErrMessage
        End If
    End Sub

function CloseAndRedirect()
{
 window.close();
 opener.window.location.href='original.aspx';



 
PNKJAsked:
Who is Participating?
 
Munawar HussainConnect With a Mentor Principal Software EngineerCommented:
you may use this metod to refresh the parent

window.opener.location.href =window.opener.location.href

thanks
0
 
PNKJAuthor Commented:
I also need to pass record id to my parent page not sure of the right syntax to pass it
Thanks
0
 
PNKJAuthor Commented:
MY Parent page = page1.aspx
On my pop up code behind o page load i get the record_id
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       record_id= Request.QueryString("record_id")  received on pop up from querystring sent from main page
              my_record_id.SelectedIndex = record_id  where my_record_id = drop down on pop up screen

User can enter the values and click on save button on my pop up screen. On click on save button
I want to redirect to the main page (page1.aspx)
and send the record_id  in my querystring from pop up screen to main page
and close the pop up window

My problem is when i do response.redirect I get the value for record_id  as 0 and pop up does not close either.Tried this coad after calling SaveData on savebutton_click event but does not work
Response.Write("<script> window.opener.location = 'contactDetail.aspx?recordId=' & record_id; window.close(); </script>")  
0
 
PNKJAuthor Commented:
MY Parent page = page1.aspx
On my pop up code behind o page load i get the record_id
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

       record_id= Request.QueryString("record_id")  received on pop up from querystring sent from main page
              my_record_id.SelectedIndex = record_id  where my_record_id = drop down on pop up screen

User can enter the values and click on save button on my pop up screen. On click on save button
I want to redirect to the main page (page1.aspx)
and send the record_id  in my querystring from pop up screen to main page
and close the pop up window

My problem is when i do response.redirect I get the value for record_id  as 0 and pop up does not close either.Tried this coad after calling SaveData on savebutton_click event but does not work
Response.Write("<script> window.opener.location = 'contactDetail.aspx?recordId=' & record_id; window.close(); </script>")  
0
All Courses

From novice to tech pro — start learning today.