views:

27

answers:

2

I would really like to be able to do this

if myRB.Checked = true then
    return redirecttorout("SomeRoute")
else
    someother route

i am used to web forms, in which i could do this in the code behind

A: 

Mvc like normal html post returns values by an input's name not id. In a radio button collection all radio buttons have the same name. So what you get back is the name of the radio button with the value of the selected radio button

The code ends up looking like

if(model.radio=="va1") { .... }

Andrey
A: 

In the action that the form posts to you need to create a string var that will hold the value.

public ActionResult GetRadioButtonValue(string RadioButtonVal)
{

The Name of the radio buttons all need to match on the view, but the value will be what is sent to the Action. Ensure that the string as seen above matches the Name of the radio buttons. It would also be a good idea to check that string for is null or empty.

string.IsNullOrEmpty(RadioButtonVal)
CrazyDart