yeah 🙁 simple question * blush *
Lets imagine i have the following enumeration:-
string[] languages = new string[] { 'en (uk)', // English (colour) 'en (us)', // English (color) 'fr', // French 'es' // Spanish }; ViewData['Languages'] = languages; ViewData['UserLanguage'] = 'en (uk)';
Armed with this, how would i display a radio button in the View? Is the only way to do this to enumerate through all the language values and render a RadioBox?
eg. pseduo-code…
<% foreach(string language in ViewData['Languages'] as string[]) { response.write Html.RadioBox(... not sure what to set in here ...) }%>
cheers!
Quick and dirty:
The problem is that you have allot of magic strings in that viewdata. What I would do is something like this:
Create a class: UserForm
the view should be strongly typed and be of type : UserForm then you could render it like :
From the controller you would :
HTH.
EDIT: OK, found it – the
RadioButtonListis an extension method in theMicrosoft.Web.Mvcnamespace (the MVCFutures project) – you can get it from here : MVCFutures