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

Javascript(?) inside RadAjaxPanel is broken after ajax update

1 Answer 167 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
CRMR
Top achievements
Rank 1
CRMR asked on 11 Oct 2012, 06:36 AM
The problem is easily reproduced with the following example:
ASPX:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Test.aspx.cs" Inherits="Sample.Test" %> 

<!DOCTYPE html> 

<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 Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
                <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
            </Scripts>
        </telerik:RadScriptManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="DropDownList1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="RadAjaxPanel1" LoadingPanelID="RadAjaxLoadingPanel1" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div>
            <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
                AutoPostBack="True" CssClass="inputField">
                <asp:ListItem Text="-Select-"></asp:ListItem>
                <asp:ListItem Text="1" Value="1"></asp:ListItem>
                <asp:ListItem Text="2" Value="2"></asp:ListItem>
            </asp:DropDownList>
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
                <asp:Panel ID="Panel1" runat="server" Visible="False" Height="100px" Width="300px">
                    panel 1
                <br />
                    <telerik:RadNumericTextBox ID="tbNum1" runat="server" MinValue="1">
                        <NumberFormat DecimalDigits="0"></NumberFormat>
                    </telerik:RadNumericTextBox>
                </asp:Panel>
                <asp:Panel ID="Panel2" runat="server" Visible="False">
                    panel 2
                </asp:Panel>
            </telerik:RadAjaxPanel>
            <telerik:RadButton ID="RadButton1" runat="server" Text="RadButton" OnClick="RadButton1_Click"></telerik:RadButton>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Metro">
            </telerik:RadAjaxLoadingPanel>
        </div>
    </form>
</body>
</html>

Code behind:
using System;
 
namespace Sample
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
        {
            System.Threading.Thread.Sleep(500);
            switch (DropDownList1.SelectedIndex)
            {
                case 1:
                    {
                        Panel1.Visible = true;
                        Panel2.Visible = false;
                        break;
                    }
                case 2:
                    {
                        Panel1.Visible = false;
                        Panel2.Visible = true;
                        break;
                    }
                default:
                    {
                        Panel1.Visible = false;
                        Panel2.Visible = false;
                        break;
                    }
            }
        }
 
        protected void RadButton1_Click(object sender, EventArgs e)
        {
 
        }
    }
}

After selecting option "1" from the dropdownlist, you see a RadNumericTextBox, in which you can enter any character and not only numbers.(same goes for other controls that use javascript such as DatePicker)
After clicking the button, the controls works like they should.

I've found out that placing the dropdownlist inside the RadAjaxPanel solves the problem, but that's not really what I want in my real web page. 
So I'd like to know if I'm not doing it right (I'm not very experienced with the Telerik Ajax controls), or is this a bug?

1 Answer, 1 is accepted

Sort by
0
Tsvetina
Telerik team
answered on 15 Oct 2012, 01:52 PM
Hello,

It is an unsupported scenario to add a RadAjaxPanel to the RadAjaxManager settings. This is what causes the problem in this case - the RadNumericTextBox scripts do not get loaded correctly. You can replace the RadAjaxPanel with an asp:Panel and the scenario will work correctly:
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="DropDownList1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="ContainerPanel" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<div>
    <asp:DropDownList ID="DropDownList1" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"
        AutoPostBack="True" CssClass="inputField">
        <asp:ListItem Text="-Select-"></asp:ListItem>
        <asp:ListItem Text="1" Value="1"></asp:ListItem>
        <asp:ListItem Text="2" Value="2"></asp:ListItem>
    </asp:DropDownList>
    <asp:Panel ID="ContainerPanel" runat="server">
        <asp:Panel ID="Panel1" runat="server" Visible="False" Height="100px" Width="300px">
            panel 1
        <br />
            <telerik:RadNumericTextBox ID="tbNum1" runat="server" MinValue="1">
                <NumberFormat DecimalDigits="0"></NumberFormat>
            </telerik:RadNumericTextBox>
        </asp:Panel>
        <asp:Panel ID="Panel2" runat="server" Visible="False">
            panel 2
        </asp:Panel>
    </asp:Panel>


All the best,
Tsvetina
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
CRMR
Top achievements
Rank 1
Answers by
Tsvetina
Telerik team
Share this question
or