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

Delete does not change entries collection on postback

4 Answers 87 Views
AutoCompleteBox
This is a migrated thread and some comments may be shown as answers.
Erik
Top achievements
Rank 2
Erik asked on 15 Jun 2013, 01:43 PM
Hi,

With the new version Q2 I found a problem. I had code with Q1 that "creates items" in the entries collection and aftre the user clicks save the collection is read again and differences are saved to the db (via oa).

Now, with Q2 however, the collection is not changed after deleting an entry.

Example:

ASPX:
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default3.aspx.vb" Inherits="WebApplication14.Default3" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <link href="style/css/site.css" rel="stylesheet" type="text/css" />
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager_App" runat="server">
    </telerik:RadStyleSheetManager>
    <title></title>
    <style type="text/css">
    </style>
</head>
<body>
    <form id="form1" runat="server">
        <div>
            <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                <Scripts>
                    <%--Needed for JavaScript IntelliSense in VS2010--%>
                    <%--For VS2008 replace RadScriptManager with ScriptManager--%>
                    <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:RadWindowManager ID="RadWindowManager_App" EnableShadow="true" runat="server" />
            <telerik:RadFormDecorator ID="RadFormDecorator_App" runat="server" />
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel_App" runat="server" />
            <asp:Panel ID="pnl_RadAjaxPanel_App_Holder" Style="width: 100%; height: 100%;" runat="server">
                <telerik:RadAjaxPanel ID="RadAjaxPanel_App" runat="server" LoadingPanelID="RadAjaxLoadingPanel_App" Style="width: 100%; height: 100%;" class="FullScreen">
                    <telerik:RadAutoCompleteBox ID="RadAutoCompleteBox1" DataTextField="Name" DataValueField="ContactId" TokensSettings-AllowTokenEditing="False" AllowCustomEntry="False" InputType="Token" Filter="Contains" runat="server" >
                    </telerik:RadAutoCompleteBox>
                    <asp:Button ID="Button1" runat="server" />
                    <asp:Button ID="Button2" runat="server" />
                </telerik:RadAjaxPanel>
            </asp:Panel>
        </div>
    </form>
</body>
</html>


VB test code:

Imports Telerik.Web.UI
 
Public Class Default3
    Inherits System.Web.UI.Page
 
    Private Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
        Dim lst_DataSource = TestItem.GetTestData
 
        RadAutoCompleteBox1.DataSource = lst_DataSource
 
    End Sub
 
    Private Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
 
        If Not HadInit Then
            RadAutoCompleteBox1.Entries.Add(New AutoCompleteBoxEntry("Kees #02.1", "3"))
            RadAutoCompleteBox1.Entries.Add(New AutoCompleteBoxEntry("Miquel #02", "8"))
            HadInit = True
        End If
 
    End Sub
 
 
    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim i As Long = RadAutoCompleteBox1.Entries.Count
    End Sub
 
    Private Sub RadAutoCompleteBox1_EntryAdded(sender As Object, e As AutoCompleteEntryEventArgs) Handles RadAutoCompleteBox1.EntryAdded
 
    End Sub
 
    Private Sub RadAutoCompleteBox1_EntryRemoved(sender As Object, e As AutoCompleteEntryEventArgs) Handles RadAutoCompleteBox1.EntryRemoved
 
    End Sub
 
    Public Property HadInit As Boolean
        Get
            Return If((ViewState("HadInit") & "").ToString.Trim.Length = 0, False, CBool(ViewState("HadInit")))
        End Get
        Set(value As Boolean)
            ViewState("HadInit") = value
        End Set
    End Property
 
 
    Private Class TestItem
        Private mlng_ContactId As Long
        Private mstr_Name As String
        Private mstr_FirstName As String
        Private mstr_City As String
        Private mstr_Country As String
        Private mobj_ParentContactId As Long? = Nothing
 
        Public Sub New()
        End Sub
        Public Sub New(ByVal alng_ContactId As Long, ByVal astr_Name As String, ByVal astr_FirstName As String, ByVal astr_City As String, ByVal astr_Country As String, Optional ByVal alng_ParentContactId As Long? = Nothing)
            ContactId = alng_ContactId
            Name = astr_Name
            FirstName = astr_FirstName
            City = astr_City
            Country = astr_Country
            ParentContactId = alng_ParentContactId
        End Sub
 
        Public Shared Function GetTestData() As List(Of TestItem)
            Dim lst As New List(Of TestItem)
 
            lst.Add(New TestItem(1, "Piet #01", "Firstname #01", "City #01", "Country #01"))
            lst.Add(New TestItem(2, "Jan #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(3, "Kees #02.1", "Firstname #02.1", "City #02.1", "Country #02.1", 2))
            lst.Add(New TestItem(4, "Karel #02.2", "Firstname #02.2", "City #02.2", "Country #02.2", 2))
            lst.Add(New TestItem(5, "Hans #02.2.1", "Firstname #02.2.1", "City #02.2.1", "Country #02.2.1", 4))
            lst.Add(New TestItem(6, "Rene #02.2.2", "Firstname #02.2.2", "City #02.2.2", "Country #02.2.2", 4))
            lst.Add(New TestItem(7, "Erik #02.3", "Firstname #02.3", "City #02.3", "Country #02.3", 2))
            lst.Add(New TestItem(8, "Miquel #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(9, "Eric #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(10, "Peter #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(11, "Zorov #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(12, "Name #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(13, "Name #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(14, "Name #02", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(15, "Name #01", "Firstname #01", "City #01", "Country #01"))
            lst.Add(New TestItem(16, "Name #16", "Firstname #02", "City #02", "Country #02"))
            lst.Add(New TestItem(17, "Name #16.1", "Firstname #16.1", "City #02.1", "Country #02.1", 16))
            lst.Add(New TestItem(18, "Name #16.2", "Firstname #16.2", "City #02.2", "Country #02.2", 16))
            lst.Add(New TestItem(19, "Name #16.2.1", "Firstname #16.2.1", "City #02.2.1", "Country #02.2.1", 18))
            lst.Add(New TestItem(20, "Name #16.2.2", "Firstname #16.2.2", "City #02.2.2", "Country #02.2.2", 18))
            lst.Add(New TestItem(21, "Name #16.3", "Firstname #16.3", "City #02.3", "Country #02.3", 16))
            lst.Add(New TestItem(22, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(23, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(24, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(25, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(26, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(27, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(28, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(29, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(30, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(31, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(32, "Name #22", "Firstname #22", "City #22", "Country #22"))
            lst.Add(New TestItem(33, "Name #22", "Firstname #22", "City #22", "Country #22"))
 
            Return lst
        End Function
 
        Public Property ContactId As Long
            Get
                Return mlng_ContactId
            End Get
            Set(ByVal value As Long)
                mlng_ContactId = value
            End Set
        End Property
 
        Public Property Name As String
            Get
                Return mstr_Name
            End Get
            Set(ByVal value As String)
                mstr_Name = value
            End Set
        End Property
 
        Public Property FirstName As String
            Get
                Return mstr_FirstName
            End Get
            Set(ByVal value As String)
                mstr_FirstName = value
            End Set
        End Property
 
        Public Property City As String
            Get
                Return mstr_City
            End Get
            Set(ByVal value As String)
                mstr_City = value
            End Set
        End Property
 
        Public Property Country As String
            Get
                Return mstr_Country
            End Get
            Set(ByVal value As String)
                mstr_Country = value
            End Set
        End Property
 
        Public Property ParentContactId As Long?
            Get
                Return mobj_ParentContactId
            End Get
            Set(ByVal value As Long?)
                mobj_ParentContactId = value
            End Set
        End Property
 
    End Class
 
 
End Class

In the example 2 items are added on loading-first-time. When you delete an entry in the box and click the first button (left side) you can see that the count is still 2 and not 1. When you go back to Q1, you will find that the count = 1.

Is this a bug or a feature? ;-)

Erik

4 Answers, 1 is accepted

Sort by
0
Erik
Top achievements
Rank 2
answered on 15 Jun 2013, 01:49 PM
Addition and workaround:
Implement the event 'EntryRemoved', then the problem is gone!

Private Sub TagBox_EntryRemoved(sender As Object, e As AutoCompleteEntryEventArgs) Handles Me.EntryRemoved
    '???
End Sub

Erik


EDIT:
This workaround does a postback when you make changes in the control. Even when AutoPostback=False?
0
Bozhidar
Telerik team
answered on 20 Jun 2013, 07:02 AM
Hi Erik,

The control is designed in such a way, so that if you attach a server event to it, the event is fired regardless of the AutoPostBack property. There is however a bug that I've found while testing your scenario - when you are handling the EntryAdded event, a postback it triggered when you delete an Entry also. This bug will be fixed in our next internal build. I've also updated your telerik points for pointing this out to us.
 

Regards,
Bozhidar
Telerik
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.
0
Erik
Top achievements
Rank 2
answered on 25 Jun 2013, 02:06 PM
Hi Bozhidar,

The "by design" comes a long way with MS too... ;-|

I provided you code where you can see a BREAKING change in functionality between Q1 and Q2. In Q1 on postback the collection is correctly filled with the elements that where selected, in Q2 it is filled with the elements selected before postback; the initial items set server side. So: When I add 3 entries on load and delete one client side, I get 3 elements returned in stead of 2. This not only wrong, it is a breaking change. I connot see the "by design" here. Also, I cannot have this with development. I need continuity. Clients do not understand why I spend more time. I can invoice Telerik?

Secondly, 1 placed the 618 internal build this afternoon. Not only does the problem persist, an other problem created a JS error:
Uncaught TypeError: Cannot read property 'AbbreviatedMonthNames' of null
Telerik.Web.UI.WebResource.axd?_TSM_HiddenField_=RadScriptManager1_TSM&compress=1&_TSM_CombinedScri…:3248
So, I'm a bit tired of being the 'guinea pig' of Telerik. (See my track record of postings)
Today I spend again an hour upgrading to .618, testing and downgrading again with no results but waisted time.

Erik
0
Bozhidar
Telerik team
answered on 26 Jun 2013, 11:32 AM
Hello Erik,

After reinspecting the provided sample I found out what was causing the issue with deleting an entry client side, and it reappearing after postback. The problem will be resolved in our next internal build. I've also attached a modified version of the page, where I've included a workaround that verifies the fix, which you can use until the next internal build.
 
As for the second issue, its related to the Calendar and is already fixed in this week's internal build.

Please except our sincere apologies for the inconvenience caused.

Regards,
Bozhidar
Telerik
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.
Tags
AutoCompleteBox
Asked by
Erik
Top achievements
Rank 2
Answers by
Erik
Top achievements
Rank 2
Bozhidar
Telerik team
Share this question
or