0

I have ASP.NET web application that contains master page. Master page contains content page. Content page contains user control. User control contains Telerik grid with its context menu.

I'd like to click the item in grid's context menu and open new popup modal window. In that window there's drop down list. I pick up some option from drop down list and click OK. I'd like to get the value selected from drop down list and use it in my ASP.NET code to proceed further.

I've tried to use hidden field to store the value from drop down list but it doesn't work because I'm not sure where hidden field should be placed.

This is my code:

Open popup window:

function ClientItemClicked(sender, eventArgs)
{
    if (eventArgs.get_item().get_value() == "excel")
    {
        var retVal = window.showModalDialog("ExportToExcelChoice.aspx", null, "dialogWidth: 400; dialogHeight: 200; center: yes; resizable: no;");
    }
}

Click "OK" to close popup window:

function ReturnValue() {
    var choice = document.getElementById("DropDownList1").value;
    if ((window.opener != null) && (!window.opener.closed)) {
        window.opener.document.getElementById("HiddenField1").value = choice;
    }
    window.close();
}

It fails on this line:

window.opener.document.getElementById("HiddenField1").value = choice;

Because hidden field is placed in user control and the code can't get the reference to hidden field.

Could someone help me to make it work?

Hmax
  • 314
  • 6
  • 16
tesicg
  • 3,971
  • 16
  • 62
  • 121

2 Answers2

0

If you're using window.open(), you can see into the parent window via the property window.opener, which will let you communicate between your parent page and the popup.

If you're using window.showModalDialog(), see the second answer to this question: window.opener alternatives

Community
  • 1
  • 1
AmericanUmlaut
  • 2,817
  • 2
  • 17
  • 27
  • As you can see from my code I've posted here I've already tried to use window.opener but it returns master page. I don't need master page. I need to access the hidden field that is placed inside user control in content page. How can I do that? – tesicg Feb 13 '13 at 08:42
0

Try this

window.opener.document.getElementById('<%= HiddenField1.ClientID %>').value = choice;
yogi
  • 19,175
  • 13
  • 62
  • 92
  • window.opener is actually content page. It means I should access to user control inside content page where hidden field is placed. How to do that? – tesicg Feb 13 '13 at 09:50
  • Or maybe there's some another way to get selected value from popup window? Maybe I don't need to use hidden field. – tesicg Feb 13 '13 at 10:14