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?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Munawar HussainPrincipal Software EngineerCommented:
you may use this metod to refresh the parent

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

thanks
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.