ListControl: SelectedIndexChanged event raised without implementing IPostBackDataHandler?

Discussion in 'ASP .Net Building Controls' started by Henri, May 19, 2005.

  1. Henri

    Henri Guest

    Hi,

    I'm designing a control that inherits ListControl
    I was surprised to see that SelectedIndexChanged is part of ListControl. So
    why doesn't it implement IPostBackDataHandler?
    I added this to my control:

    Function LoadPostData(postDataKey As String, postCollection As
    NameValueCollection) As Boolean Implements IPostBackDataHandler.LoadPostData

    Dim changed As Boolean
    For i As Integer = 0 To Items.Count - 1
    Dim item As ListItem = Items(i)
    Dim selected As Boolean
    selected = Not postCollection(UniqueID & "_" & item.Value) Is
    Nothing
    If selected <> item.Selected Then
    changed = True
    End If
    item.Selected = selected
    Next

    Return changed

    End Function

    but now I can't raise any SelectedIndexChanged from
    RaisePostDataChangedEvent() as this event belongs to the base class
    ListControl and I get a compile error if I try to.

    I really don't understand the logic of ListControl: must I check if values
    have changed between posts myself or does ListControl do it by itself? So if
    ListControl do it itself, what is a class that inherits ListControl supposed
    to do when implementing IPostBackDataHandler?

    Can you help me?
    Thanks

    Henri
    Henri, May 19, 2005
    #1
    1. Advertising

  2. Henri

    MasterGaurav Guest

    ListControl is abstract class. It's subclasses - CheckBoxList, DDL,
    ListBox, RadioButtonList -- all implement IPostBackDataHandler.

    btw, make an explicit implementation of the methods. For example:

    Private Sub
    System.Web.UI.IPostBackDataHandler.RaisePostDataChangedEvent()
    Implements IPostBackDataHandler.RaisePostDataChangedEvent
    ' Do whatever you want to.
    End Sub




    Cheers,
    Gaurav Vaish
    http://mastergaurav.org
    http://mastergaurav.blogspot.com
    ------------------------
    MasterGaurav, May 20, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nathan Sokalski
    Replies:
    0
    Views:
    819
    Nathan Sokalski
    Oct 25, 2007
  2. Andrew Dawson

    Implementing IPostBackDataHandler in a custom web control with VB.NET

    Andrew Dawson, Aug 9, 2004, in forum: ASP .Net Building Controls
    Replies:
    1
    Views:
    410
    Teemu Keiski
    Aug 12, 2004
  3. Scott Blood

    Custom ListControl OnFocus Event not working

    Scott Blood, Jul 31, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    158
    Scott Blood
    Jul 31, 2006
  4. NH
    Replies:
    2
    Views:
    526
    Andrew L. Van Slaars
    Dec 17, 2004
  5. J055
    Replies:
    0
    Views:
    477
Loading...

Share This Page