Combobox not allowing selections after jquery ajax request inside onclientselecteditemchanged event

2 posts, 0 answers
  1. dd
    dd avatar
    12 posts
    Member since:
    Mar 2010

    Posted 17 Sep 2013 Link to this post

    I have a combobox on a page that loads other comboboxes dynamically when the user selects a value.  After this happens once, the user can no longer make a selection in the original combobox.  I made a simple project to reproduce this behavior.  Any ideas as to what I can do to fix this? 

    Edit: Telerik version 2009.3.1314.35. Can't upgrade because of project specs.  Thanks.

    <%@ Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits="TestProject1.WebForm1" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <!DOCTYPE html>
    <head runat="server">
        <script type="text/javascript" src="//"> </script>
        <script type="text/javascript">
            var currentIndex = -1;
            function changeFilter(sender, args) {
                    type: "POST",
                    url: "WebForm1.aspx?action=test&row=" + currentIndex,
                    success: function (data) {
                        var arr = data.split("|");  //0 is result, 1 is html to add
                        var result = arr[0];
                        if (result == "success") {
                            var html = arr[1];
                return false;
        <form id="form1" runat="server">
            <telerik:RadScriptManager id="rsm1" runat="server"></telerik:RadScriptManager>
                <telerik:RadComboBox ID="cmbxExistingFilters" runat="server" ClientIDMode="Static" AutoPostBack="false"
                         EmptyMessage="Saved Filters" RegisterWithScriptManager="false" AllowCustomText="false"
                        AppendDataBoundItems="true" EnableAutomaticLoadOnDemand="false" OnClientSelectedIndexChanged="changeFilter"
                        EnableVirtualScrolling="false" >
                <div id="hiddenContainer" runat="server" style="display:none;"></div>
                <div id="container0" runat="server"></div>

    Imports Telerik.Web.UI
    Imports System.IO
    Public Class WebForm1
        Inherits System.Web.UI.Page
        Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            If HttpContext.Current.Request.Headers("X-Requested-With") = "XMLHttpRequest" Then ' if ajax postback
                Dim row As String = Request.QueryString("row")
                Response.Write("success|" + RenderCustomControl(BuildStatesTextbox(row)) + _
                               RenderCustomControl(BuildSectorCombobox(row)) + "|")
            ElseIf IsPostBack Then
                Me.container0.ClientIDMode = UI.ClientIDMode.Static
            End If
        End Sub
        Private Sub BindToCombo(ctrl As RadComboBox)
            For i As Integer = 0 To 5
                Dim rci As New RadComboBoxItem
                rci.Text = "hey_" + i.ToString
                rci.Value = "hey_" + i.ToString
        End Sub
        Private Function RenderCustomControl(ctrl As Control) As String
            Dim sb As New StringBuilder
                If ctrl IsNot Nothing Then
                    Using sw As New StringWriter(sb)
                        Using html As New HtmlTextWriter(sw)
                            ctrl.Page = Me
                        End Using
                    End Using
                End If
            Catch ex As Exception
                Response.Write(ctrl.ID + " Fail<br>")
            End Try
            Return sb.ToString
        End Function
        ''' <summary>
        ''' Create textbox to display states
        ''' </summary>
        ''' <param name="row"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function BuildStatesTextbox(row As String) As RadTextBox
            Dim txtboxStates As New RadTextBox
            txtboxStates.Width = 150
            txtboxStates.ID = "tbxStates_" + row
            txtboxStates.ClientIDMode = UI.ClientIDMode.Static
            txtboxStates.Attributes("onclick") = "alert('" + row + "');"
            txtboxStates.AutoPostBack = False
            'txtboxStates.Style.Add("display", "none")
            txtboxStates.ReadOnly = True
            txtboxStates.RegisterWithScriptManager = False
            Return txtboxStates
        End Function
        ''' <summary>
        ''' Create combobox to let the user choose the sector
        ''' </summary>
        ''' <param name="row"></param>
        ''' <returns></returns>
        ''' <remarks></remarks>
        Private Function BuildSectorCombobox(row As String) As RadComboBox
            Dim cmbxSectors As New RadComboBox
            cmbxSectors.Width = 150
            cmbxSectors.ID = "cmbxSectors_" + row
            cmbxSectors.ClientIDMode = UI.ClientIDMode.Static
            For i = 0 To 5
                Dim cmbxItem As New RadComboBoxItem()
                cmbxItem.Text = "bye_" + i.ToString
                cmbxItem.Value = "bye_" + i.ToString
            cmbxSectors.AutoPostBack = False
            ' cmbxSectors.Style.Add("display", "none")
            cmbxSectors.RegisterWithScriptManager = False
            Return cmbxSectors
        End Function
    End Class
  2. Nencho
    Nencho avatar
    1812 posts

    Posted 20 Sep 2013 Link to this post

    Hello David,

    Thank you for contacting Telerik Support.

    I was able to replicate the described issue. It seems that the problem is related with the scripts loaded on the page and with the RadScriptManager. Therefore, I would suggest you to currently use the asp:ScriptManager, until we investigate and troubleshoot the problem.

    Hope this would help. Please excuse us for any inconveniences caused.

    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 the blog feed now.
Back to Top