I have a repeater that has a javascript containing itemtemplate. Like this:
<itemtemplate>
<script><%#ShowImg(Eval("ID"))%></script>
<itemtemplate>
With normal postback, the script are getting evaluated and images are shown by executing the script. however, if the repeater is updated via AjaxManager/Panel, the script is not evaluated. How do I cause the script to be reinitiated?
10 Answers, 1 is accepted
The regular RadAjax does not have this issue.
Please enclose this script in RadScriptBlock. Here is an example:
<itemtemplate>
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript"><%#ShowImg(Eval("ID"))%></script>
</telerik:RadScriptBlock>
<itemtemplate>
Best wishes,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Specifically, what should be included and what can't be included?
This is a new control similar to RadCodeBlock and you can use it to execute scripts blocks inside the updating areas. Example:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="Button1">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Panel1"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="Button2">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="Button2"></telerik:AjaxUpdatedControl>
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<asp:Button ID="Button1" runat="server" />
<asp:Button ID="Button2" runat="server" />
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" >
<asp:Panel ID="Panel1" runat="server">
<asp:Button ID="Button3" runat="server" />
<telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
<script type="text/javascript">
alert(1);
</script>
</telerik:RadScriptBlock>
</asp:Panel>
</telerik:RadAjaxPanel>
The alert will be executed only on Button1 and Button3
click. This info will be added to the Prometheus help for the official release.
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
This works in RadAjaxPanel, but doesn't seem to work with RadAjaxManager in a more complicated setting:
I have a repeater with some buttons in its itemtemplate that updates itself.
When I wrap it with RadAjaxPanel, the RadScriptBlock behaves correctly.
However, if I use RadAjaxManager to add ajaxsetting to the repeater (both control to ajaxify and the updated control are the repeater), it does not work. Javascript does not get evaluated on update.
The asp:Repeater control does not render according to the requirements for ajax "aware" control, specifically it does not render in a single tag - this is discussed since the RadCallback era. Please nest the Repeater in asp:Panel and set it as initiator and updated control and this should do.
Kind regards,
Steve
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
The RadAjaxPanel however works as expected.
This problem is fixed and you can request latest "Prometheus" dev build via support ticket.
Sincerely yours,
Vlad
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
