Apply Custom Id and Default Value to MVC5 Radiobuttonfor

217 views Asked by At

I need to have unique Ids for each radio button in a collection in order to attach a jQuery function to only one radio button in the collection. However as noted in this article [link]http://goodcoffeegoodcode.blogspot.com/2010/02/aspnet-mvc-htmlradiobutton-generates.html the MVC radiobuttonfor helper applies the same Id to all buttons of a radio button collection. As the linked article suggests I can override this behavior by applying new {@id = ""} but this prevents me from assigning a default selection for the radio button collection. Is there a way I can apply a unique Id and a default selection to a MVC radiobuttonfor? If the default MVC radiobuttonfor will not allow me to apply both has someone created a custom MVC helper that does this? Thanks

0

There are 0 answers