PDA

View Full Version : [CLOSED] checkbox callback wrong value



jstifel
May 28, 2014, 11:33 PM
Hi there, I have developed a user control which allows to generate a CRUD form based on a JSON file.
For this purpose the user control creates grid and edit window with form for editing purposes.

I have located the initialisation code like this



Protected Overrides Sub OnInit(e As EventArgs)
MyBase.OnInit(e)
End Sub

Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
InitControl()
OnAfterInit(e)
End Sub


Inside the InitControl routine I initialise fields like:



ElseIf _type = "checkbox" Then
Dim cb As New Ext.Net.Checkbox With {.FieldLabel = p("title").ToString, .Flex = "1"}
ctrl = cb



I first create form fields, then add them to form and finally add form to window and add window to user control.

My problem is that whenever I check the checkbox and click save button, in code behind when evaluating value for checkbox it tells the value is the one before modifying it at the screen. If I check true, I receive false, which happens to be the value before. If I then uncheck and hit save, I received true.

Do you have any idea of what could be wrong here?
I know it is difficult to understand specially considering I should submit a full example ir order for you to evaluate but wonder if this has happened before to someone and you already know how to fix it?

Daniil
May 29, 2014, 5:05 AM
Hi @jstifel,

Yes, it is difficult to say something concrete without a full test case to reproduce.

Please check in a request (when you click the Save button) that a correct Checkbox's value is being submitted from client. By the way, you use a Button's Click DirectEvent? How do you retrieve a Checkbox's value? Where?

Also you can debug a Checkbox's LoadPostData.

jstifel
May 29, 2014, 8:48 AM
Yes I use DirectEvents to post data back to server.

I have checked debugging request.params on callback and realised the problem is checkbox data is not always submitted, sometimes the request.params shows the checkbox's clientid and value and some other simply checkbox's clientid does not list at all in request.params.

Is it there any reason for a field defined in a formpanel not to be listed in request.params on callback?

Daniil
May 29, 2014, 12:15 PM
If a Checkbox is not checked, it is not submitted at all. So, if it is not submitted, its value on server should be false.