Regular input in ASP.NET

Posted by coffeeaddict on Stack Overflow See other posts from Stack Overflow or by coffeeaddict
Published on 2010-06-07T18:54:26Z Indexed on 2010/06/07 19:12 UTC
Read the original article Hit count: 283

Filed under:
|

Here's an example of a regular standard HTML input for my radiobuttonlist:

<label><input type="radio" name="rbRSelectionGroup" checked value="0" />None</label>
<asp:Repeater ID="rptRsOptions" runat="server">
<ItemTemplate>
    <div>
    <label><input type="radio" name="rbRSelectionGroup" value='<%# ((RItem)Container.DataItem).Id %>' /><%# ((RItem)Container.DataItem).Name %></label>
    </div>
</ItemTemplate>
</asp:Repeater>

I removed some stuff for this thread, one being I put an r for some name that I do not want to expose here so just an fyi.

Now, I would assume that this would or should happen:

  1. Page loads the first time, the None radio button is checked / defaulted
  2. I go and select a different radiobutton in this radiobutton list
  3. I do an F5 refresh in my browser
  4. The None radio button is pre-selected again after it has come back from the refresh

but #4 is not happening. It's retaining the radiobutton that I selected in #2 and I don't know why. I mean in regular HTML it's stateless. So what could be holding this value? I want this to act like a normal input button.

I know the question of "why not use an ASP.NET control" will come up. Well there are 2 reasons:

  1. The stupid radiobuttonlist bug that everyone knows about
  2. I just want to brush up more on standard input tags
  3. We are not moving to MVC so this is as close as I'll get and it's ok, because the rest of the team is on par with having mixed ASP.NET controls with standard HTML controls in our pages

Anyway my main question here is I'm surprised that it's retaining the change in selection after postback.

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about html