Clientscripts only works on initial load of ajaxpanel

1 Answer 51 Views
Ajax AjaxPanel
Mark
Top achievements
Rank 1
Mark asked on 08 Dec 2022, 10:53 PM

Hello friends

Scenario:

On hovering the textbox an alert is triggered from clientscript.

The controls are placed inside a RadAjaxpanel.

Question:

Why does this setup only works on inital load?

If I submit the page, the clientscript does not work anymore.

Check my demo below.

 

kind regards

Mark


<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>

    <form id="form1" runat="server">

        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
            <Scripts>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.Core.js"></asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQuery.js"></asp:ScriptReference>
                <asp:ScriptReference Assembly="Telerik.Web.UI"
                    Name="Telerik.Web.UI.Common.jQueryInclude.js"></asp:ScriptReference>
            </Scripts>
        </telerik:RadScriptManager>

        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Metro" >
        </telerik:RadAjaxLoadingPanel>
        


        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

            <script type="text/javascript">

                $(document).ready(function () {

                    $("#TextBox1").hover(function () {
                        alert('test');
                    });
                });

            </script>

        </telerik:RadScriptBlock>


        <telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server" Height="100%" Width="100%">

            <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            <asp:Button ID="Button1" runat="server" Text="Submit" />

        </telerik:RadAjaxPanel>

    </form>
</body>
</html>

using System;

public partial class mytest : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
}


 

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 13 Dec 2022, 12:27 PM

Hi Mark, 

Hope you are doing well!

Just place the RadScriptBlock script inside the RadAjaxPanel (as shown in the example here) and it will start to execute after submit:

<telerik:RadAjaxPanel ID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" runat="server" Height="100%" Width="100%">
    <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">

            $(document).ready(function () {

                $("#TextBox1").hover(function () {
                    alert('test');
                });
            });

        </script>

    </telerik:RadScriptBlock>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="Button1" runat="server" Text="Submit" />

</telerik:RadAjaxPanel>

 

Regards,
Rumen
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Mark
Top achievements
Rank 1
commented on 13 Dec 2022, 12:58 PM

Thank's Rumen! , it works.

Pretty straight forward.  ;)

 

Kind regards

Mark

 

 

 

Rumen
Telerik team
commented on 13 Dec 2022, 01:00 PM

For nothing! The pleasure is mine! Happy holidays, Mark!
Tags
Ajax AjaxPanel
Asked by
Mark
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or