You must Sign In to post a response.
  • Category: ASP.NET

    Ho to pass modalpopup window value to parent window textbox

    Dear Friends
    In my web form i have one text box and two button[1 for save detail and 1 for popup window].

    when i will click 2nd button popupwindow will be opened. i placed gridview inside of popup window with link button. this link button showing some data.. now i will click that link button, this value should be display in parent window text box how its possible
  • #764836
    Try this:
    //.. Call this function on PopUp button
    function showPopUp()
    var returnVal = window.showModalDialog("PopUp.aspx", 'jain', "dialogHeight: 560px; dialogWidth: 360px; edge: Raised; center: Yes; help: Yes; resizable: Yes; status: No;");
    document.getElementById("txtBox1").value = returnVal;

    //... Call this function on close button which exist inside PopUp page
    function Close()
    var txtValue = document.getElementById('linkButton');
    window.returnValue = txtValue.value;//.. Important line
    return false;

    Hope this will help you.
    Shashikant Gurav

  • #764839
    Hi Navaneeth,

    Use Hidden field, from child window you can save the value into Hidden field and you can able to reuse it in parent window, because Hidden field value is available through out the browser.

    Hope this will helpful to you...

    Give respect to your work, Instead of trying to impress your boss.

    Blog :

  • #764840

    Easiest and simple option would be to use Session or hidden field. Since you are getting very small data there won't be any performance impact too.

    Asheej T K

  • #764844
    There are couple of ways to pass value from child window to parent window
    1. using window.opener
    - 'window.opener' will always represent to parent window, so on child window you can use it in javascript, see below snippet
    <script type="text/javascript">
    function SetName() {
    if (window.opener != null && !window.opener.closed) {
    var txtName = window.opener.document.getElementById("txtName");
    txtName.value = document.getElementById("ddlNames").value;

    2. using session variable, means to store value in session variable and then access it on parent window

    Editor, DotNetSpider MVM
    Microsoft MVP 2014 [ASP.NET/IIS]

  • #764893
    Hai Navaneetha Krishnan,
    You can pass the return values in the callback function of the model popup where you can have your values which you want when the popup is getting closed.
    Below are the links which can be helpful to you for the code snippets:

    Hope it will be helpful to you.

    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)

  • Sign In to post your comments