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

Passing Args Client-Side to Client-Side with Radopen

1 Answer 142 Views
Window
This is a migrated thread and some comments may be shown as answers.
Alan Shaw
Top achievements
Rank 1
Alan Shaw asked on 05 Jul 2016, 11:19 PM

I'm modernizing some really old code that used the old Rad toolkit.  I found that the "argument" property is not persisting.  I was able to change the window's close code around to pass the element in the close() function, but can't find a way to do this when opening the form.  I'm using VS2013 with ASP.NET AJAX and Telerik.Web.UI v2015.3.930.45.

Please take a look and advise.  I don't want to make a round-trip to the server for this.  I also found that javascript globals do not persist between postbacks.  So I can't use that sloppy method either.  FYI - I keep the window open and the user may initiate a number of postbacks with an runat=server asp:button before I close it from the client side.

 

Javascript being called from a client-side radmenu click on the main page.  "notesExist" is a string value.

function ShowNotesForm(id, notesExist) {

    var oWnd = window.radopen("Dialogs/Notes.aspx?DocID=" + id, "NotesDialog");
    oWnd.argument = notesExist;

}

 

Javascript within my Notes.aspx:

 

        <telerik:RadScriptBlock runat="server">
            <script type="text/javascript">
                $(document).ready(function () {
                    alert(GetRadWindow().Argument);
                });
            </script>
        </telerik:RadScriptBlock>

 

I've tried reading GetRadWindow().Argument in other sections like after a button-click on the client-side, but put it here to make it easy to replicate on your end.

 

1 Answer, 1 is accepted

Sort by
0
Marin Bratanov
Telerik team
answered on 06 Jul 2016, 08:14 AM

Hi Alan,

JavaScript variables do not persist after postbacks because the entire page is disposed.

What you can look into is using AJAX an ensure the objects that contain your custom fields are not part of the response.

In this case the "argument" field in the client-side object of the RadWindow is merely a custom field you can add to any JavaScript object, and it behaves like one, so you should avoid disposing it.

Another very important note is that JavaScript is case-sensitive, so the fields must have exactly the same names. In the provided snippet the "a" in "argument" is lowercase when set, but is read with an uppercase letter in the content page. You should unify that.

The following article shows an example usage of this approach that you can use to compare: http://docs.telerik.com/devtools/aspnet-ajax/controls/window/how-to/using-radwindow-as-a-dialog.

Regards,

Marin Bratanov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Window
Asked by
Alan Shaw
Top achievements
Rank 1
Answers by
Marin Bratanov
Telerik team
Share this question
or