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
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