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

[Solved] Javascript in updated control

10 Answers 386 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
SamVanity
Top achievements
Rank 2
SamVanity asked on 18 Nov 2007, 01:58 PM
Hi,

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

Sort by
0
SamVanity
Top achievements
Rank 2
answered on 18 Nov 2007, 03:46 PM
nevermind. I figure it out with some changes in my script and use the ResponseScript.Add method of the panel to achieve the effect I want.
0
SamVanity
Top achievements
Rank 2
answered on 19 Nov 2007, 06:26 PM
while I found the workaround, I still think this is an issue with the current AjaxPanel/manager that needs to be addressed.

The regular RadAjax does not have this issue.
0
Vlad
Telerik team
answered on 20 Nov 2007, 07:02 AM
Hi Sam,

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
0
SamVanity
Top achievements
Rank 2
answered on 20 Nov 2007, 09:45 AM
it works. now I don't have to use responsescript. Good solution. Where can I find out more about this control? I searched the help file but didn't find anything about it before.

Specifically, what should be included and what can't be included?
0
Steve
Telerik team
answered on 20 Nov 2007, 09:56 AM
Hello Sam Van,

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.

Regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
SamVanity
Top achievements
Rank 2
answered on 20 Nov 2007, 04:21 PM
BUG REPORT

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.
0
Steve
Telerik team
answered on 20 Nov 2007, 04:47 PM
Hello Sam Van,

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
0
SamVanity
Top achievements
Rank 2
answered on 21 Nov 2007, 03:34 AM
I just tried it, and it doesn't work. The button inside the repeater when clicked does not cause the script to be re-evaluated. I put the repeater in an ASP:Panel and use AjaxManager to make the panel the initiator / updated control. The panel is ajaxified, but the script does not get re-evaluated.

The RadAjaxPanel however works as expected.
0
Vlad
Telerik team
answered on 22 Nov 2007, 01:01 PM
Hi Sam,

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
0
SamVanity
Top achievements
Rank 2
answered on 22 Nov 2007, 03:18 PM
Thanks, I will do that. In the meantime, please update my telerik point for this report.
Tags
Ajax
Asked by
SamVanity
Top achievements
Rank 2
Answers by
SamVanity
Top achievements
Rank 2
Vlad
Telerik team
Steve
Telerik team
Share this question
or