I have a ASP.NET mvc application with the view like:
@using (Html.BeginForm("FormSubmit", "HomeController", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal" }))
{
<fieldset>
<!-- Form Name -->
<legend>Survey Form</legend>
<br>
<br>
<centre> <p> This is a survey for User X. <p>
</centre>
<!-- Multiple Radios -->
<div class="form-group">
<label class="col-md-4 control-label" for="q1">Any Plans to attend college?</label>
<div class="col-md-4">
<div class="radio">
<label for="q1-0">
<input type="radio" name="Q1" id="q1-0" value="1">
Yes
</label>
</div>
<div class="radio">
<label for="q1-1">
<input type="radio" name="Q1" id="q1-1" value="2">
No
</label>
</div>
</div>
</div>
<input type="submit" name="SaveButton" value="Save" align="center">
</fieldset>
}
I created the controller in HomeController:
[HttpPost]
public ActionResult FormSubmit(int Q1)
{
return Content(Request.Form["SaveButton"]);
// return RedirectToAction("Index");
}
Now when I try the button it gives me a:
Server Error in '/surveyapps' Application.
The resource cannot be found.
I did exactly as said in this post at stack-overflow: asp.net mvc form not posting parameter values
Any way the error could be resolved? I sam sure if I get the form values then I can just insert them into database.