Custom checkbox control and postback

A

apple

Hello, please help me
I create a set of custom controls with IPostBackDataHandler, 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.AddAttribute("type", "checkbox")
output.AddAttribute("ID", Me.UniqueID)
output.AddAttribute("name", Me.UniqueID)
output.AddAttribute("value", "True")
If CBool(Me.SettingsItem.SettingsKeyValue) Then
output.AddAttribute(HtmlTextWriterAttribute.Checked, "checked")
End If
output.WriteFullBeginTag("span")
output.Write(Me.SettingsItem.SettingsKeyResx & Me.SettingsItem.SettingsKeyType.Name)
output.WriteEndTag("span")
output.RenderBeginTag("input")
output.RenderEndTag()

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


Public Overridable Function LoadPostData(ByVal postDataKey As String, ByVal values As System.Collections.Specialized.NameValueCollection) As Boolean Implements IPostBackDataHandler.LoadPostData
Dim presentValue As Object = Me.SettingsItem.SettingsKeyValue
Dim postedValue As Object = CObj(values(postDataKey))
If Not presentValue.Equals(postedValue) Then
Me.SettingsItem.SettingsKeyValue = postedValue
Return True
End If
Return False
End Function
 
J

Jimmy [Used-Disks]

If Not presentValue.Equals(postedValue) Then
Me.SettingsItem.SettingsKeyValue = postedValue
Return True
End If

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

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top