3
I have 2 Radio Buttons, and I would like when I mark one, the other to cancel.
Follow the image of what is occurring:

Code:
@Html.RadioButton("teste", "teste", true) Teste
@Html.RadioButton("concessionaria", "concessionaria", false) Concessionária
3
I have 2 Radio Buttons, and I would like when I mark one, the other to cancel.
Follow the image of what is occurring:

Code:
@Html.RadioButton("teste", "teste", true) Teste
@Html.RadioButton("concessionaria", "concessionaria", false) Concessionária
2
Put it like this:
@Html.RadioButton("teste", "teste", true)
@Html.RadioButton("teste", "concessionaria")
Because the input type radio must bear the same name, the difference being value.
Example with form:
<form action="/Estudo/Post" method="post" enctype="multipart/form-data">
@Html.RadioButton("teste", "teste", true)
@Html.RadioButton("teste", "concessionaria")
<button>Enviar</button>
</form>
Rendered Html:
<form action="/Estudo/Post" method="post" enctype="multipart/form-data">
<input checked="checked" id="teste" name="teste" type="radio" value="teste" />
<input id="teste" name="teste" type="radio" value="concessionaria" />
<button>Enviar</button>
</form>
Note that the two have the same name with different value that can be recovered by the method Post.
Recovering by the Method Post
public ActionResult Post(string teste)
{
return View();
}
Debug:

Browser other questions tagged razor asp.net-mvc-4
You are not signed in. Login or sign up in order to post.
You can use attr('checked', true) true or false in case.
– f.fujihara