Aviral Kumar
Aviral Kumar

Reputation: 824

Transferring values from popup page to parent page

I have a parent page inner4.aspx and a popup page popupemail.aspx . Now whats happening is I am extracting email ids in popup and displaying in the gridview and when the user selects an email id it gets tranferred through a javascript function to the parent page.

CODE FOR PARENT:

function setText1(txt) {
            document.getElementById('TextBox4').value = txt;
        }

CODE FOR POPUP:

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = GridView1.SelectedRow;
        //TextBox2.Text = row.Cells[1].Text;


        ScriptManager.RegisterStartupScript(this,GetType(), "settxt", "setText1('"+ row.Cells[1].Text + "');", true);
    }

The values are not getting transferred . Help please

Upvotes: 0

Views: 1351

Answers (3)

dhinesh
dhinesh

Reputation: 4764

Otherwise after the selected index changed set some property in the server side

in the cs
protected string SelectedValue{
   get {
      return "whatever";
   }
}


protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {
        GridViewRow row = GridView1.SelectedRow;
        //TextBox2.Text = row.Cells[1].Text;


        SelectedValue = row.Cells[1].Text
    }

in the js
$(document).ready(function(){
    var selectedValue= '<%=SelectedValue%>';
    window.opener.document.getElementById("TextBox4").value = selectedValue;

});

there could be syntactical mistakes. Hope this helps.

Upvotes: 0

Imran Rizvi
Imran Rizvi

Reputation: 7438

Copy the modified line to your code

ScriptManager.RegisterStartupScript(this,GetType(), "settxt", "window.opener.setText1('"+ row.Cells[1].Text + "');", true);

Upvotes: 1

Gaurav Agrawal
Gaurav Agrawal

Reputation: 4431

you can call parent page by using javascript by using

window.opener.document.getElementById("TextBox4").value = txt;

or you can call parent page function by uisng same way

window.opener.setText();

setText() function written on parent page not in popup page.

Upvotes: 0

Related Questions