Marcin
Marcin

Reputation: 3262

Validation prevent check box to auto postback

I have following checkboxes on my page:

<asp:CheckBox ID="rbBuilding" runat="server" AutoPostBack="True" OnCheckedChanged="HandlerPackageOnCheckedChanged" Checked="True" CausesValidation="False"   />
<asp:CheckBox ID="rbContent" runat="server" AutoPostBack="True" OnCheckedChanged="HandlerPackageOnCheckedChanged" CausesValidation="False" />

There is an logic on postback based on combination of checkboxes clicked. Everything is working fine except one case:

I'm opening additional telerik radwindow which has some validation within its own validation group. If I close the window with any validation error, then the first click on any of that checkboxes does not do postpack.

Only FIRST click is not working. next time I click everything is working fine. I've tried to add check boxes to theirs own validation group and change casing validation to true. But behaviour is exactly the same. When I add test javascript method to onclick for that checkboxes then this method is fired without issue. There is just no postback.

I also tried to reset all validators for window validation group on window close, they are reset, but behaviour is not checking, and first click is not working.

UPDATE:

I've made one more check and realized it only happens if I do in javascript:

window.Page_ClientValidate("MyGroup")

Which I have to do before do some calculations on popup window. During dynamic validators, when updating validatable controls eveything is working properly, even if validation fails. So the problem is *Page_ClientValidate*

Upvotes: 2

Views: 1565

Answers (1)

Tom
Tom

Reputation: 1179

I know this is an old question but I ran into almost the exact issue and thanks to the following link I was able to resolve the issue:

Issue with postbacks and clicking on controls twice

I ended up adding this code to my code behind to add a javascript event handler for the checkbox's click event:

Checkbox1.Attributes.Add("onclick", "checkboxChanged();");

I then added the following javascript:

function checkboxChanged(arg1) {
  Page_BlockSubmit = false;
}

The checkbox in my situation was also set to have CausesValidation set to false but I don't think that's required for this fix. Hopefully this helps someone.

Upvotes: 2

Related Questions