开发者

Radiobutton.Checked not working for first button in group

开发者 https://www.devze.com 2022-12-09 05:22 出处:网络
I\'ve got a check for the first radiobutton in my group of ASP.NET radiobuttons.For some reason, the page loads and that first button is automatically checked, not that we\'re setting it开发者_如何学J

I've got a check for the first radiobutton in my group of ASP.NET radiobuttons. For some reason, the page loads and that first button is automatically checked, not that we're setting it开发者_如何学JAVA to be checked..it must naturally check itself since it's the first in the group.

However, when I actually check that it's checked in an if statement (so that I can act on it) it returns false even though it's checked for sure when the page renders

myRadioButton.Checked ends up with false. Not sure why.


ended up being a logic problem. I was binding after my check logic.


My dollars are that you're setting the button state during Page_Load and forgetting to check whether IsPostBack is true/false. Your code likely looks like this:

Page_Load(...) {
  SetFormState()
}    

When it should look like this:

Page_Load(...) {
    if (!IsPostBack) {
      SetFormState()
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消