This is a migrated thread and some comments may be shown as answers.

Question on returning values to a parent window.

3 Answers 88 Views
Window
This is a migrated thread and some comments may be shown as answers.
Sam
Top achievements
Rank 1
Sam asked on 23 May 2011, 09:19 PM
Hi,

I am basing my code off of the sample you have here:
http://demos.telerik.com/aspnet-ajax/window/examples/dialogreturnvalue/defaultcs.aspx

In your sample, on the aspx page for "Dialog2.aspx" is a javascript function:
function returnValue()
{
    //get the RadComboBox's selected item's text
    var combo = $find("<%= RadComboBox1.ClientID %>");
    var selectedCapital = combo.get_text();
 
    //Get a reference to the parent page (Default.aspx)
    var oWnd = GetRadWindow();
 
    //get a reference to the second RadWindow
    var dialog1 = oWnd.get_windowManager().getWindowByName("RadWindow1");
 
    // Get a reference to the first RadWindow's content
    var contentWin = dialog1.get_contentFrame().contentWindow
     
    //Call the predefined function in Dialog1
    contentWin.populateCityName(selectedCapital);
 
    //Close the second RadWindow
    oWnd.close();
}

This line here, works great, but I need to try to modify:
contentWin.populateCityName(selectedCapital);

instead of calling a function (in this case "populateCityName") I want to be able to set the control's value directly.
Is this possible?
So instead of the above line of code, I would like to do something like:
contentWin.document.getElementById("cityName").value = "hello";

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 24 May 2011, 09:27 AM
Hello Sam,

In such scenario, the logic stays basically the same. The difference is that you should pass the new value as a parameter and then set it where you need it in the function on the other page.
e.g.
contentWin.populateCityName(someValue);

and in the content page
function populateCityName(arg)
{
   document.getElementById("someElement").value = arg;
}



Greetings,
Georgi Tunev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Sam
Top achievements
Rank 1
answered on 24 May 2011, 12:34 PM
Thank you for your response!

However, I understand the demo on the site as well as what you posted, but that's not what I'm trying to do.
I'm trying to avoid using a function on the content page.
Instead of:  contentWin.functionName(someValue)

I want to directly use "getElementById" to access controls on the content page without having to use a function to contain the calls to getElementById.

I know it's not elegant to do it this way, but I'm trying to update our existing app and this would be the easiest way to integrate the radwindow with the existing code structure.

Thanks!

0
Accepted
Georgi Tunev
Telerik team
answered on 24 May 2011, 02:06 PM
Hello again Sam,

I apologize for the misunderstanding.
Yes, this is possible - you need to get a reference to the RadWindow first - in the sample below I used $find(), but if you are using RadWindowManager, you could use GetRadWindowManager().getWindowByName("winName") as well.
function setValueInWindow()
{
    //get a reference to the RadWindow
    var oWnd = $find("<%= RadWindow1.ClientID %>");
    var conentWin = oWnd.get_contentFrame().contentWindow;
    conentWin.document.getElementById("txtInput").value = "hello";
}

Note however, that this would not be applicable for complex scenarios where you have nested controls in the content page (Master / Content page for example). In such case, the ClientID of the control differs than the original one and you will need to hardcode it as you will not be able to use
<%= someControl.ClientID %>


Best wishes,
Georgi Tunev
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

Tags
Window
Asked by
Sam
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Sam
Top achievements
Rank 1
Share this question
or