Hi,
How to redirect from jquery tabs to tabs im mvc
I have a page that have 3 tabs("Detail", "Material", "Summary") which after I submit form in "Detail" tab, it will redirect to "Material" tab, and from "Material" tab to "Summary".
The image of the page as below
View
<script>
$(function () {
$("#tabs").tabs();
});
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1">Details</a></li>
<li><a href="#tabs-2">Material</a></li>
<li><a href="#tabs-3">Summary</a></li>
</ul>
<div id="tabs-1">
@using (Html.BeginForm("AddPlatform", "Home", FormMethod.Post))
{
@Html.AntiForgeryToken()
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<label for="name" class="mr-sm-2">Name:</label>
<span>@Html.EditorFor(model => model.req_name, new { htmlAttributes = new { @class = "form-control mr-sm-2" , style = "width:800px" } })</span>
<br/>
<label for="email" class="mr-sm-2">Badge Number:</label>
<span>@Html.EditorFor(model => model.badge_num, new { htmlAttributes = new { @class = "form-control mr-sm-2", style = "width:800px" } })</span>
<br/>
<label for="phone" class="mr-sm-2">Line :</label>
<span>@Html.EditorFor(model => model.line, new { htmlAttributes = new { @class = "form-control mr-sm-2", style = "width:800px" } })</span>
<br/><br/>
<div align="center">
<input type="submit" value="Save" class="btn btn-primary" />
</div>
}
</div>
<div id="tabs-2">
Content for Tab 2 goes here.<br />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
<div id="tabs-3">
Content for Tab 3 goes here.<br />
Lorem ipsum dolor sit amet, consectetuer adipiscing elit,
sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
</div>
</div>
Controller
public ActionResult AddPlatform()
{
return View();
}
[HttpPost]
public ActionResult AddPlatform(ItemModel Imodel)
{
try
{
// Insert new record.
Requester model = new Requester
{
req_name = Imodel.req_name,
badge_num = Imodel.badge_num,
line = Imodel.line,
req_date = DateTime.Now,
status = Imodel.status
};
db.Requesters.Add(model);
db.SaveChanges();
}
catch (DbEntityValidationException ex)
{
foreach (var entityValidationErrors in ex.EntityValidationErrors)
{
foreach (var validationError in entityValidationErrors.ValidationErrors)
{
Response.Write("Property: " + validationError.PropertyName + " Error: " + validationError.ErrorMessage);
}
}
}
return RedirectToAction("FormRequest", "Home");
}