ajax stops working after deleting the last item from listbox

2 posts, 0 answers
  1. ido nahmias
    ido nahmias avatar
    64 posts
    Member since:
    May 2006

    Posted 29 May 2014 Link to this post

    Hello,

    Ajax stops working after deleting the last item from Listbox

    I have listbox, panel and 2 buttons- the first button deletes items from the listbox using java script (1) and the second button is  used to send ajax requests in order to hide and show the panel (2).

    While deleting the items from the listbox, the ajax buttons works and hides/shows the panel but after deleting the last item from the listbox, the ajax stops working.

    There is no error in the client side and neither on server side- I add break points at the server side in the Page_Load, I notice the function wasn't even called.


    (1)-listBox.deleteItem(selectedItem);
    (2)- panel.visible=false/true

    Thanks,





  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 30 May 2014 in reply to ido nahmias Link to this post

    Hi ido nahmias,

    Please have a look into the sample code snippet which works fine at my end. Please provide your code if it doesn't help.

    ASPX:
    <telerik:RadListBox ID="RadListBox1" runat="server">
        <Items>
            <telerik:RadListBoxItem Text="Item1" />
            <telerik:RadListBoxItem Text="Item2" />
            <telerik:RadListBoxItem Text="Item3" />
        </Items>
    </telerik:RadListBox>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">
        <telerik:RadTextBox ID="RadTextBox1" runat="server" Text="Test">
        </telerik:RadTextBox>
    </telerik:RadAjaxPanel>
    <telerik:RadButton ID="RadButton1" runat="server" Text="DeleteItem" AutoPostBack="false"
        OnClientClicked="DeleteSelectedItem">
    </telerik:RadButton>
    <telerik:RadButton ID="RadButton2" runat="server" Text="Change Visibility" OnClick="RadButton2_Click">
    </telerik:RadButton>

    JavaScript:
    <script type="text/javascript">
        function DeleteSelectedItem(sender, args) {
            var listbox = $find("<%=RadListBox1.ClientID %>");
            listbox.trackChanges();
            listbox.get_items().removeAt(listbox.get_selectedIndex());
            listbox.commitChanges();
            var button = $find("<%=RadButton2.ClientID%>");
            button.click();
        }
    </script>

    C#:
    protected void RadButton2_Click(object sender, EventArgs e)
    {
        if (RadAjaxPanel1.Visible==true)
            RadAjaxPanel1.Visible = false;
        else
            RadAjaxPanel1.Visible = true;
    }

    Thanks,
    Shinu.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top