Welcome Guest Search | Active Topics | Sign In | Register

Bug found? Options
THoMaSiN
Posted: Wednesday, May 21, 2008 6:18:27 AM
Rank: Member
Groups: Member

Joined: 12/5/2007
Posts: 27
Hello,

I've been researching for HOURS why suddenly my eo.datepicker wasn't preserving its state !!

It turned out that I just introduced a new code in the LoadCompleted event on the page that adds a control to the form. doing that, the datepicker loses all track of ViewState while the other ASP controls work perfectly ... hard to find ... so far I've just tested it and prove it to NOT work on DatePicker. this is the code I use in the LoadComplete event for the page;

Code: Visual Basic.NET
' Get the div from the page if it exists
        Me.msgDiv = Me.FindControl("MessageHeader")

        ' if it doesn't, attempt to add a new div disabled since EO gives problems
        If msgDiv Is Nothing Then

            msgDiv = New html.HtmlGenericControl("div")
            msgDiv.ID = "MessageHeader"

            Try

                Me.Form.Controls.AddAt(0, msgDiv)

            Catch ex As Exception

                Try

                    Me.Form.Controls.Add(msgDiv)

                Catch ex2 As Exception

                    Exit Sub

                End Try

            End Try

        End If
eo_support
Posted: Friday, May 23, 2008 11:46:15 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,094
Hi,

We looked into the issue. The problem is caused by the way the state information is loaded. The information is loaded by index, not by name. So when you insert a new control as the first child in the form, this new control actually gets the original first control's state data, and the state data for the DatePicker control is also shifted to somebody else. The easiest way to fix this problem is to place a static PlaceHolder control in your form, and then add your dynamic control as child control of that PlaceHolder control. That way it only affects state information inside that branch, not anybody else.

Thanks

THoMaSiN
Posted: Sunday, May 25, 2008 12:42:27 PM
Rank: Member
Groups: Member

Joined: 12/5/2007
Posts: 27
mmmm, yeah, actually, that's useful for a control that will be going to a specific page, but this control is actually in every page and re-usability and maintenance issues prevent me from adding a place holder in every single page ...

Any other control in ASP.NET seems to keep the View State fine, even if its index is after the new inserted index ... but ...

Thanks anyway for the research ;)


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.