RadAjaxManager.GetCurrent(Page) inside .JS file

2 posts, 0 answers
  1. Taiseer
    Taiseer avatar
    37 posts
    Member since:
    Oct 2007

    Posted 04 Dec 2011 Link to this post

    Dear all,

    I have a user control with (RadAjaxProxyManager) and the (RadAjaxManager) on the ASP.NET page where the user control lives 

    I need to put the below JS function isnide .JS file not on the page directly. I want to get rid of the RadCodeBlock tag as well I'm combining JS in files. I dont want to have inline JS functions on ASP.NET pages.

    <rad:RadCodeBlock ID="RadCodeBlock1" runat="server">
    <script type="text/javascript">
     function refreshAttachmentGrid(arg) {
    $find("<%= RadAjaxManager.GetCurrent(Page).ClientID %>").ajaxRequest("RefreshAttachment");
    }
    </script>
    </rad:RadCodeBlock>


    The code works fine, all I need is to move it to JS file.

    Thanks in advance.

    Taiseer

  2. Andrey
    Admin
    Andrey avatar
    836 posts

    Posted 07 Dec 2011 Link to this post

    Hello Taiseer,

    Server expressions are not resolved when they are placed outside of the ASPX page. So if you place them in external JS file you will end up with a string representation of the statement instead of an object.

    One workaround for this is to use global variable in which to store the object returned by the statement. Then in your external file to use the $find() function and to pass the global variable as a parameter to this method.

    If you do not want any JavaScript code in your ASPX page, you could assign value to this variable in code-behind by using ScriptManager, RegisterClientScripts method.


    All the best,
    Andrey
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top