keep user checked radiobtn checked even after postback

后端 未结 2 1988
眼角桃花
眼角桃花 2021-01-26 09:44

I have the following radiocontrols with Default checked to \"All\". If user checks some other radio button and submits, on postback i want to retain the checked button, so user

相关标签:
2条回答
  • 2021-01-26 10:08

    Here's a quick way:

    var value = window.location.href.match(/[?&]type=([^&#]+)/) || [];
    
    if (value.length == 2) {
        $('input[name="EventType"][value="' + value[1] + '"]').prop('checked', true);
    }
    

    Here's a demo: http://jsfiddle.net/agW9g/

    0 讨论(0)
  • 2021-01-26 10:22

    If your server page doesn't redirect somewhere else usually the content is the same. Oh, you can use the server controls and keep the state of the control in the ViewState.

    0 讨论(0)
提交回复
热议问题