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
    Hi,
    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
    window.close();
    return false;
    }

    Hope this will help you.
    Regards,
    Shashikant Gurav
    shashikantgurav22@gmail.com

  • #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.

    N@veen
    Blog : http://naveens-dotnet.blogspot.in/

  • #764840
    Hi,

    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.


    Regards,
    Asheej T K
    Microsoft MVP[ASP.NET/IIS]
    DotNetSpider MVM

  • #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;
    }
    window.close();
    }
    </script>

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

    Thanks
    Koolprasd2003
    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:

    http://stackoverflow.com/questions/13834950/get-values-from-modal-popup-in-parent-windows-button-click-event
    http://stackoverflow.com/questions/9276086/popup-window-to-return-data-to-parent-on-close

    Hope it will be helpful to you.

    Regards,
    Pawan Awasthi(DNS MVM)
    +91 8123489140 (whatsApp), +60 14365 1476(Malaysia)
    pawansoftit@gmail.com


Sign In to post your comments