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

There a way to send values from the parent to the dialog window on open?

5 Answers 330 Views
Window
This is a migrated thread and some comments may be shown as answers.
Fred
Top achievements
Rank 1
Fred asked on 21 Oct 2008, 06:15 AM
There a way to send values from the parent to the dialog window, on open?

5 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 21 Oct 2008, 07:45 AM
Hello Fred,

Yes, you can send them either in a form of an argument by using the client side API as shown in this demo:
http://demos.telerik.com/aspnet/prometheus/Window/Examples/DialogReturnValue/DefaultCS.aspx

Or in the query string for the opened page:
http://demos.telerik.com/aspnet/prometheus/Window/Examples/UsingURLForServerArguments/DefaultCS.aspx



Regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Fred
Top achievements
Rank 1
answered on 21 Oct 2008, 01:46 PM
I was looking at the demos, but still have a problem with having the parent page process something at the server level.

So with the querty string, lets say I do open up the dialog window, I then do something server side and close the window.

But in the demo the parent window display the data from the child but it seems to be only client level data. I need to take the data from the client and then process the parent page.

Currently I can doing a refresh on the parent page, but it seems that the parent page is refreshing before the child page ever finishes.
0
Fred
Top achievements
Rank 1
answered on 21 Oct 2008, 05:27 PM


Ok I got it responding the way I wanted.

I took off the call to closeClientcallBack off of the button and instead, as I saw somewhere in your docs, I did a page register on the button click and places the script call there for page startup.  and in that function called the refresh parent page script.
0
Fred
Top achievements
Rank 1
answered on 24 Oct 2008, 05:26 PM
Is there a way to see from the demo link, what the dialog window does? the dialog.aspx, how does it display the argument sent it form the parent?

http://demos.telerik.com/aspnet/prometheus/Window/Examples/DialogReturnValue/DefaultCS.aspx

Demo shows you how to call the window and sent the arguments. What's the receiving end on the dialog page look like?



0
Georgi Tunev
Telerik team
answered on 27 Oct 2008, 08:23 AM
Hi Fred,

The dialog page is plain HTML - you can examine it by using the View Source option of the browser - for convenience I am pasting it below:

<html> 
    <head><title
    Dialog 
</title>         
        <style> 
         
        * 
        { 
            font: normal 11px Arial, Verdana, Sans-serif;        
        } 
                 
        .bButton 
        { 
            width: 100px; 
            height: 20px; 
            border: 1px; 
            background-image: url(../bBtuttonBg.gif); 
            background-repeat: no-repeat; 
            background-color: #fff;          
            color: #666666; 
            vertical-align: middle; 
        }                
        </style> 
    </head> 
    <body onload="ConfigureDialog()"
        <form method="post" action="Dialog.aspx?rwndrnd=0.5277324723346717" id="Form1"
<div> 
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNzgzNDMwNTMzZGTfQYqO1vSLjNVkidFMaGo1uxEP5w==" /> 
</div> 
 
        <script type="text/javascript"
            //This code is used to provide a reference to the radwindow "wrapper" 
            function GetRadWindow() 
            { 
                var oWindow = null
                if (window.radWindow) oWindow = window.radWindow; 
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow; 
                return oWindow; 
            }        
             
            function ConfigureDialog() 
            { 
                //Get a reference to the radWindow wrapper 
                var oWindow = GetRadWindow(); 
                 
                //Obtain the argument  
                var oArg = oWindow.Argument; 
                 
                //Use the argument 
                var oArea = document.getElementById("DialogInfoArea"); 
                oArea.value = oArg.TextValue; 
                oArea.style.color = oArg.Color; 
                oArea.style.backgroundColor = oArg.BackColor;                    
            } 
                         
            function OK_Clicked() 
            { 
                var oWindow = GetRadWindow(); 
                 
                //Get current content of text area 
                var oNewText = document.getElementById("DialogInfoArea").value; 
                alert ("Text to be returned to main page: " + oNewText); 
                 
                //Variant1: Passing the argument to the close method will result in the same behavior 
                oWindow.close(oNewText); 
                                         
                //Variant2: Possible to set the argument property of RadWindow here, and read it in the OnClientClose event handler! 
                //oWindow.argument = oNewText;           
            } 
             
            function Cancel_Clicked() 
            { 
                var oWindow = GetRadWindow();            
                oWindow.close(); 
            }                
        </script>    
   
        Text from main page (possible to change): 
        <br/><textarea id="DialogInfoArea" rows="5" cols="38"></textarea> 
        <br/>        
        <button onclick="OK_Clicked(); return false;" class="bButton">OK</button> &nbsp;&nbsp;       
        <button onclick="Cancel_Clicked(); return false;" class="bButton">Cancel</button>    
        </form> 
    </body> 
</html> 
 
 

In addition, you can check the following documentation topic where this example is explained in details:
http://www.telerik.com/help/aspnet-ajax/window_programmingusingradwindowasadialog.html


Since you are talking about server-side logic, note that the communication between the content and the parent page is done on the client only - just like with any other popup. Once you receive the argument on the client, you need to send it somehow to the server. This (sending arguments from the client to the server with JavaScript) is a general task - for example you can use __doPostBack() or RadAjax's ajaxRequest call to do this.

Kind regards,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Window
Asked by
Fred
Top achievements
Rank 1
Answers by
Georgi Tunev
Telerik team
Fred
Top achievements
Rank 1
Share this question
or