How to choose asp.net RadioButton with javascript when autostart is enabled

Scenario:

  • Multiple radio buttons with the specified GroupName and AutoPostBack="true".
  • for styling, the radio button is hidden by js, and a click on its container (td) is processed through js
  • when the td button is clicked, the script โ€œclicksโ€ the input element and launches asp.net auto postback

It performs a postback and removes PageLoad on the server, but the event in the codeb does not fire.

+2
javascript html radio-button
Dec 11 '12 at 19:34
source share
1 answer

I posted this in case someone would be bad enough to hit this issue.

The problem is very accurately mentioned in the comment on this answer https://stackoverflow.com/a/464829/

There is one thing with .click (): if you change the selected radio value using javascript, this โ€œchangeโ€ event does not fire in IE (I tried IE8) - Michiel Reyers

This seems like a mess with asp.net postback event handling. Therefore, in order to raise it, we clearly choose it first:

 $(this).find("input").prop("checked", true); $(this).find("input").click(); 
+2
Dec 11 '12 at 19:39
source share



All Articles