Thursday, 18 April 2024

Form Control Post C# ASP.Net MVC

 Form Post is a simple process to submit data to the server. C# works the same as other languages like PHP works. Problems arise with the radio button and checkbox. These controls are different from the textbox. So we need different ways to detect user selection. This is post will help you to learn checkbox and radio button selection using form POST.

Radio Button selection detect 

HTML

<form method="post" >
  <
input type="radio"  name="SalaryPerson" value="1" checked/> Salary Person
  <input type="radio" name="SalaryPerson" value="0" /> Self Empployee
 
<input type="submit" value="Save" >
</
form>


Model

public class RadioModel
{
    public string SalaryPerson { get; set; }
}

Access on server

[HttpPost]     

public ActionResult ReadRadio(PostRequirementModel data)
{
    string Radio = data.SalaryPerson; ;
    ViewBag.Data = Radio;
    return View();
}

Next Topic

No comments:

Post a Comment