Custom checkbox control and postback

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • apple

    Custom checkbox control and postback

    Hello, please help me
    I create a set of custom controls with IPostBackDataHa ndler, and postback processing.
    All worked correctly, only custom checkbox control postback value change only if I do change status to enabled/checked.
    So, I can only set status to checked, not the other.
    How I can correct this, may be this is because I use Objects in LoadPostData, but all another controls types (texboxes) work fine...

    Here is code for render:
    output.AddAttri bute("type", "checkbox")
    output.AddAttri bute("ID", Me.UniqueID)
    output.AddAttri bute("name", Me.UniqueID)
    output.AddAttri bute("value", "True")
    If CBool(Me.Settin gsItem.Settings KeyValue) Then
    output.AddAttri bute(HtmlTextWr iterAttribute.C hecked, "checked")
    End If
    output.WriteFul lBeginTag("span ")
    output.Write(Me .SettingsItem.S ettingsKeyResx & Me.SettingsItem .SettingsKeyTyp e.Name)
    output.WriteEnd Tag("span")
    output.RenderBe ginTag("input")
    output.RenderEn dTag()

    Here is code for LoadPostData (Me.SettingsIte m saved in ViewState):


    Public Overridable Function LoadPostData(By Val postDataKey As String, ByVal values As System.Collecti ons.Specialized .NameValueColle ction) As Boolean Implements IPostBackDataHa ndler.LoadPostD ata
    Dim presentValue As Object = Me.SettingsItem .SettingsKeyVal ue
    Dim postedValue As Object = CObj(values(pos tDataKey))
    If Not presentValue.Eq uals(postedValu e) Then
    Me.SettingsItem .SettingsKeyVal ue = postedValue
    Return True
    End If
    Return False
    End Function
  • Jimmy [Used-Disks]

    #2
    Re: Custom checkbox control and postback

    > If Not presentValue.Eq uals(postedValu e) Then[color=blue]
    > Me.SettingsItem .SettingsKeyVal ue = postedValue
    > Return True
    > End If[/color]

    If the value is not present, then the box was not checked.

    --
    -Jimmy
    Used-Disks:



    Comment

    Working...