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

RadAjaxManager.GetCurrent(Page) inside .JS file

1 Answer 34 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Taiseer
Top achievements
Rank 1
Taiseer asked on 04 Dec 2011, 11:35 PM

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

1 Answer, 1 is accepted

Sort by
0
Andrey
Telerik team
answered on 07 Dec 2011, 05:48 PM
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
Tags
Ajax
Asked by
Taiseer
Top achievements
Rank 1
Answers by
Andrey
Telerik team
Share this question
or