I am new to this working environment using aspnet and I would like to know if there is a way to show an input when selecting an item on the radio button without trying to use javascript.
Method created in the controller called tg04Personas
public string radio(FormCollection frm)
{
string genderradio = frm["personaTipo"].ToString();
if (genderradio == "natural")
{
Response.Redirect("~/tg04Personas/CreateNatural");
return "";
}
else if (genderradio == "juridica")
{
Response.Redirect("~/tg04Personas/Create");
return "";
}
{
Response.Redirect("~/tg04Personas");
return "";
}
}
Created View
@model PiramideWeb.Models.tg04Personas
@{
ViewBag.Title = "Choose";
}
<h2>Selccione el tipo de Persona</h2>
@using (Html.BeginForm("radio", "tg04Personas", FormMethod.Post))
{
<div class="form-group">
@Html.LabelFor(model => model.personaTipo, htmlAttributes: new { @class = "control-label col- md-2" }) <br />
<div class="col-md-10">
Natural @Html.RadioButton("personaTipo", "natural",true, new { htmlAttributes = new { @class = "form-control"} })
Juridica @Html.RadioButton("personaTipo", "juridica", new { htmlAttributes = new { @class = "form-control"} })
Extranjera @Html.RadioButton("personaTipo", "extranjera", new { htmlAttributes = new { @class = "form-control"} })
</div>
</div>
<input type="submit" value="Seleccionar" />
}
Doubt
- You can call the method without having to click on the submit button dynamically, or you can not perform this action. I appreciate your attention.