简体   繁体   中英

ASP.Net RadioButtonList in a Group with JQuery

I've got some radiobuttons in my webform, they are all part of the same group

                <asp:RadioButton runat="server" ID="rbMonFriWkends" GroupName="HoursWkSelect" CssClass="ChbxToggler TogglesChbx-chbxToToggle VisibleToggle VisiToggles-divToToggle" />

I've got some JQuery handlers:

$(".ChbxToggler").click(function(){
    //Logic that pulls out any css classes that should be toggled and toggles 'em.
    return false;//This is part of the problem
});

$(".VisibleToggle").click(function(){
    //Logic that pulls out any css classes that should be toggled and toggles 'em.

    return false;//This is part of the problem
});

It all works but for one thing - the selection (ie the radiobutton which actually gets checked) never changes.

ie. if I click Radiobutton#1 everything toggles as it should but the selected radiobutton remains the one that was selected before the handler(s) run. So the selection remains the same but the GUI changes as it should.

Can someone help or at least explain what I'm doing wrong? Happy to post more code if it'll help ...

I think you answered that yourself with the comment next to return false;

That appears to be cancelling your selection?

If you click a radio, your function is getting called, you are doing the work ie

Logic that pulls out any css classes that should be toggled and toggles 'em.

but you are then cancelling the selection with return false;

You would only need to use return false if you click a link or post a form and you dont want to reload/navigate the page, but on a radio, this is not needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM