Begin form firing HTTP GET instead of HTTP POST in MVC.
@using (Html.BeginForm("CreateProject", "ProjectSubmit", FormMethod.Post, new { @id = "CreateProject" }))
{
@Html.AntiForgeryToken()
@Html.Hidden("IsPostBack", (String)ViewBag.IsPostBack.ToString())
<div id="page-content-wrapper">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
<div class="white-place">
<div class="col-md-12">
<!-- Custom Tabs -->
<div class="nav-tabs-custom">
<ul class="nav nav-tabs">
<li class="active"><a href="#tab_1" data-toggle="tab" aria-expanded="true">Requester Information</a></li>
<li class=""><a href="#tab_2" data-toggle="tab" aria-expanded="false">Project Information</a></li>
<li class=""><a href="#tab_3" data-toggle="tab" aria-expanded="false">System/Module Information</a></li>
</ul>
<div id="lblMessage" style="display:none ;color:red;font-size: 15px!important;margin: -36px 154px -25px;float:right"></div>
<!-- tab-content -->
<div class="tab-content">
<div class="tab-pane active" id="tab_1">
<div class="filterd-restuls scroll-style">
<div class="panel-heading" style="background-color:#4599c3; color:white;">
<h4 class="panel-title text-left">Requester Information</h4>
</div>
<div class="tab-table">
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Requester Name :</label>
</div>
<div class="col-sm-7">
@Html.TextBox("RequesterName", "", new { @class = "form-control",@readonly="readonly" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Requester Office Phone :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("RequesterOfficePhone", "", new { @class = "form-control" })
</div>
<div class="col-sm-2">
<label class="control-label">+91-80-80668678</label>
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Requester Mobile Phone :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("RequesterMobilePhone", "", new { @class = "form-control", @placeholder = "+91-80-80668678" })
</div>
<div class="col-sm-2">
<label class="control-label">+91-80-80668678</label>
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Customer Is Requestor :</label>
</div>
<div class="col-sm-7">
@Html.CheckBox("CustomerIsRequestor", new { @checked = "false", @class = "checkbox" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Customer Name :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("CustomerName", "", new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Customer Office Phone :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("CustomerOfficePhone", "", new { @class = "form-control" })
</div>
<div class="col-sm-2">
<label class="control-label">+91-80-80668678</label>
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Customer Mobile Phone :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("CustomerMobilePhone", "", new { @class = "form-control" })
</div>
<div class="col-sm-2">
<label class="control-label">+91-80-80668678</label>
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">L1 Manager AMAT :</label>
</div>
<div class="col-sm-7">
@Html.TextBox("L1ManagerAMAT", "", new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">BU Manager AMAT :</label>
</div>
<div class="col-sm-7">
@Html.TextBox("BUManagerAMAT", "", new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Project Priority :</label>
</div>
<div class="col-sm-7">
@Html.TextBox("ProjectPriority", "", new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="search-footer">
<a href="#" id="NextTabRequesterInfo" tabindex="9" class="btn btn-flat btn-success">Next</a>
</div>
</div>
</div>
</div>
</div>
<!-- /.tab-pane -->
<div class="tab-pane" id="tab_2">
<div class="filterd-restuls scroll-style">
<div class="panel-heading" style="background-color:#4599c3; color:white;">
<h4 class="panel-title text-left">Project Information</h4>
</div>
<div class="tab-table">
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Project Type :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.DropDownList("ProjectType", new SelectList((System.Collections.IEnumerable)ViewBag.ProjectTypesList, "TypeId", "TypeDesc"), new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Project Title :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.TextBox("ProjectTitle", "", new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">PBG :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.DropDownList("PBGName", new SelectList((System.Collections.IEnumerable)ViewBag.PBGList,"PBG_Id","PBG_Desc"),new { @class="form-control"})
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">PLC :</label>
</div>
<div class="col-sm-7">
@Html.DropDownList("PLCName", new SelectList((System.Collections.IEnumerable)ViewBag.PLCList, "PlcId", "PlcDesc"), new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">PLC Program :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.EnumDropDownListFor(item => item.PLCProgram_Values, new { @class = "form-control" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Tool No :</label>
</div>
<div class="col-sm-7">
@Html.TextBox("ToolNo", "", new { @class = "form-control disabled" })
</div>
</div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
<label class="control-label">Tool Category :</label>
<span class="text-red text-bold">*</span>
</div>
<div class="col-sm-7">
@Html.DropDownList("ToolCategory", new SelectList((System.Collections.IEnumerable)ViewBag.ToolCategoryList, "ToolCategoryId", "ToolCategoryDesc"), new { @class = "form-control" })
</div>
</div>
<div>
<div class="form-group col-xs-12 col-sm-12 col-md-12 col-lg-12">
<div class="col-sm-3">
</div>
<div class="col-sm-7">
<a href="#" id="PreviousTabModuleInfo" tabindex="9" class="btn btn-flat btn-danger">Previous</a>
<input type="submit" name="button" value="Submit" id="SubmitProject" class="btn btn-primary btn-flat" />
<input type="reset" name="button" value="Cancel" class="btn btn-primary btn-flat" />
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
}
Here is the controller code will this work?
[HttpPost]
public ActionResult Project(ProjectModel project, String button)
{
switch (button)
{
}
}
How to get the form data to controller and call the HTTP POST?
Aucun commentaire:
Enregistrer un commentaire