Search code examples
asp.netvb.netradio-buttononcheckedchanged

In asp.net, page_load occuring before radio button OnCheckedChanged event


I have two radio button on my asp.net page, with AutoPostBack = True
When I click on either of those, they each set a flag SaveData=False

However, when I click on them, the page_load event occurs first, so the page_load event saves the data, then the radiobutton_OnCheckedChanged event is triggered.

How can I trigger the OnCheckedChanged before the page_load event?


Solution

  • You can't trigger the OnCheckedChanged before radiobutton_OnCheckedChanged because that's the normal page life cycle.

    You can check in Page_Load if Page.IsPostBack is true or not, and then don't save (or save) the data.