title: Best way to pass values from popup page to parent page
body: <p>I have a main page for customer in which i need to select location for the customer . to pick a location we have desined a popup page which has a grid which displays all locations . once user pics the loction that particular location should be returned back to the main page . </p>
  
  <p>Location object contains feilds - LocId,LocName,LocState,LocCountry,PinCode  .
  The entire location object should be returned to the main page not a single value .</p>
  
  <p>My code for opening location is </p>
  
  <pre><code>&lt;asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="../Content/Images/search.png" Height="21px" ToolTip="Search Location" Width="21px"
                          OnClientClick="ShowLocation();" /&gt;
  </code></pre>
  
  <hr>
  
  <pre><code>function ShowLocation() {
      window.showModalDialog('../StandardLookups/Location.aspx', '_blank', 'dialogWidth:820px; dialogHeight:400px; dialogLeft:250px; dialogTop:250px;status:no; scroll:no; help:no; resizable:no,edge: Raised,doPostBackAfterCloseCallback: false,postBackElementId: null');
  
  }
  </code></pre>
  
  <hr>
  
  <p>Code in popup window once the row is selected by the user</p>
  
  <pre><code> protected void btnSelect_Click(object sender, EventArgs e)
      {
          List&lt;object&gt; locationValues = gvLocationLookup.GetSelectedFieldValues(new string[] { "LocId", "LocName", "LocState","LocCountry","PinCode" });
  
          var locationValue = (object[])locationValues[0];
  
          var location= new Location
          {
              LocId = (int?)locationValue[0],
              LocName = (string)locationValue[1],
              LocState = (string)locationValue[2]
              LocCountry = (string)locationValue[3]
              PinCode =   (string)locationValue[4]
          };
          Session["SELECTED_LOCATION"] = location;
          Response.Write("&lt;script&gt; window.opener.location.reload(false); window.close();&lt;/" + "script&gt;");
          Response.End();
      }
  </code></pre>
  
  <p>Currently i use sessions values to move values . Is there any better approaches ? </p>