views:

286

answers:

0

Hi I have a set of radio buttons for "yes" and "no" values which have a name="choice". "yes" is checked by default. They're both runat="server". I read the choice on postback like below. It works perfectly fine as long as the validation doesn't fail. For example, if I select "no" and validation fails on postback, I still see "no" selected. But if I submit the form after correcting everything, the value read is "yes" on server side! Is this a bug in .net, and if so, how do i fix this?

            foreach (string key in Request.Form.AllKeys)
        {
            if (key.EndsWith("choice"))
                return Request.Form[key] == "yes";
        }