Separate form into two columns - asp.net-mvc

I tried splitting this form into two columns from another ticket I found on here but it is not working correctly. (technically four columns - column one left labels, column two left fields, column three right labels, column four right fields). Unfortunately, it is all messed up. Here is my view:
#using (Html.BeginForm("EditTechTicket", "Ticket", FormMethod.Post))
{
#Html.AntiForgeryToken()
<div class="container">
<hr />
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<form class="form-large">
<div class="left-col">
<div class="form-group">
#Html.LabelFor(model => model.OpenUserId, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DisplayFor(model => model.OpenUser.FullName)</span>
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.OpenDate, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DisplayFor(model => model.OpenDate)</span>
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.CloseDate, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DisplayFor(model => model.CloseDate)</span>
</div>
</div>
</div>
<div class="right-col">
<div class="form-group">
#Html.LabelFor(model => model.CategoryId, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DropDownList("CategoryId", null, htmlAttributes: new { #class = "form-control" })</span>
#Html.ValidationMessageFor(model => model.CategoryId, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.TechnicianId, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DropDownList("TechnicianId", null, htmlAttributes: new { #class = "form-control" })</span>
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.TicketStatusId, htmlAttributes: new { #class = "control-label col-md-2" })
<div class="col-md-10">
<span style="font-weight:normal;">#Html.DropDownList("TicketStatusId", null, htmlAttributes: new { #class = "form-control" })</span>
#*<span style="font-weight:normal;">#Html.DropDownListFor(model => model.TicketStatus, (IEnumerable<SelectListItem>)ViewBag.StatusId)</span>*#
</div>
</div>
</div>
</form>
<hr />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Update" class="btn btn-default" />
</div>
</div>
</div>
}
and here is the code I added to my bootstrap.css file:
.form-large {
/*max-width: 884px;*/
padding: 15px 15px 10px;
margin: 0 auto 20px;
background-color: #fff;
border: 1px solid #d6d6d6;
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
-moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
box-shadow: 0 1px 2px rgba(0,0,0,.05);
}
.left-col {
/*display: inline-block;*/
width: 442px;
}
.right-col {
/*display: inline-block;*/
width: 442px;
}
Here is the rendered code:
<form action="/Ticket/EditTechTicket/f2780334-6f2b-4a68-8733-a8d7d6cd28cc" method="post"><input name="__RequestVerificationToken" type="hidden" value="9yy11Toj0Cg4Tse3jDfhf6L8ETk651NHGW_t-u0wWIlsgmzBS6ay7sk0eJif1pmr0tFT5dYyXxvJwMRnIxiJ2ZmfrChgnXVZlJgZQR9-0GM1" /> <div class="container">
<hr />
<form class="form-large">
<div class="left-col">
<div class="form-group">
<label class="control-label col-md-2" for="OpenUserId">Ticket Owner</label>
<div class="col-md-10">
<span style="font-weight:normal;">Daniel Blois</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="OpenDate">Opened</label>
<div class="col-md-10">
<span style="font-weight:normal;">5/26/2015</span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="CloseDate">Closed</label>
<div class="col-md-10">
<span style="font-weight:normal;">5/26/2015</span>
</div>
</div>
</div>
<div class="right-col">
<div class="form-group">
<label class="control-label col-md-2" for="CategoryId">Category</label>
<div class="col-md-10">
<span style="font-weight:normal;"><select class="form-control" id="CategoryId" name="CategoryId"><option value="00000000-0000-0000-0000-000000000000">Microsoft Office</option>
</select></span>
<span class="field-validation-valid text-danger" data-valmsg-for="CategoryId" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="TechnicianId">Technician</label>
<div class="col-md-10">
<span style="font-weight:normal;"><select class="form-control" id="TechnicianId" name="TechnicianId"><option value="00000000-0000-0000-0000-000000000000">Daniel Blois</option>
<option value="999600fc-709e-4463-84ad-d26894babb54">Mike Smith</option>
</select></span>
</div>
</div>
<div class="form-group">
<label class="control-label col-md-2" for="TicketStatusId">Status</label>
<div class="col-md-10">
<span style="font-weight:normal;"><select class="form-control" id="TicketStatusId" name="TicketStatusId"><option value="00000000-0000-0000-0000-000000000000">Active</option>
<option value="a297c792-1224-4605-8a72-48d218d569e6">Deffered</option>
<option value="553f4c93-4a72-44bd-a9ce-fab4f87d4e08">Closed</option>
</select></span>
</div>
</div>
</div>
</form>
<hr />
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Update" class="btn btn-default" />
</div>
</div>
</div>
</form>

I assumed like this way...DEMO
HTML Part:
<div class="col-md-12 col-xs-12" >
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputName">Ticket Owner</label></div>
<div class="col-md-4 col-xs-4">
<label for="exampleInputName2">Daniel Blois</label>
</div></div>
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputEmail2">Opened</label>
</div>
<div class="col-md-4 col-xs-4">
<label for="exampleInputEmail2">5/26/2015</label>
</div></div>
</div>
<div class="col-md-12 col-xs-12" >
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputName2">Closed</label></div>
<div class="col-md-4 col-xs-4">
<label for="exampleInputName2">5/26/2015</label></div></div>
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputEmail2">Category</label>
</div>
<div class="col-md-4 col-xs-4">
<select class="form-control" id="CategoryId" name="CategoryId"><option value="00000000-0000-0000-0000-000000000000">Microsoft Office</option>
</select>
</div></div>
</div>
<div class="col-md-12 col-xs-12" >
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputEmail2">Technician</label>
</div>
<div class="col-md-4 col-xs-4">
<select class="form-control" id="CategoryId" name="CategoryId"><option value="00000000-0000-0000-0000-000000000000">Microsoft Office</option>
</select>
</div></div>
<div class="col-md-6 col-xs-6">
<div class="col-md-4 col-xs-4">
<label for="exampleInputEmail2">Status</label>
</div>
<div class="col-md-4 col-xs-4">
<select class="form-control" id="CategoryId" name="CategoryId"><option value="00000000-0000-0000-0000-000000000000">Microsoft Office</option>
</select>
</div></div>
</div>
Add this CSS
.col-xs-12{margin-bottom: 5px;}
.col-md-12 {margin-bottom: 5px;}

Related

Radio-Buttons overlapping each other

I am building a form using bootstrap 4.3 with few Radio-Buttons, but the issue is, it overlaps each other as shown below.
I tried it in jsfiddle and the result is same. Here is my working in jsfiddle: https://jsfiddle.net/hifni/ky3xzej0/7/
My Razor page looks like this:
<div class="alert alert-info">
<p>The request will enable your Credit Balance to be in your account for future trading/settlement.</p>
<footer class="blockquote-footer">Subject to T&C</footer>
</div>
<style>
.form-control {
height: auto;
}
</style>
#using (Html.BeginForm())
{
#Html.AntiForgeryToken()
<div class="form">
<hr />
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<div class="form-group">
#Html.HiddenFor(model => model.AccountId)
<input type="hidden" id="tempStore" />
#Html.HiddenFor(model => model.SendSMS)
#Html.HiddenFor(model => model.RequiresApproval)
</div>
<div class="form-group">
<label>Pick a Settlement Mode</label>
<div class="form-control">
<div class="form-check">
#Html.RadioButtonFor(model => model.IsSettlementOnHold, "No", new { #class = "form-check-input", #id = "rbIsSettlementOnHold_No" })
#Html.Label("rbIsSettlementOnHold_No", "Standard ", new { #class = "form-check-label" })
#Html.RadioButtonFor(model => model.IsSettlementOnHold, "Yes", new { #class = "form-check-input", #id = "rbIsSettlementOnHold_Yes" })
#Html.Label("rbIsSettlementOnHold_Yes", "On Request ", new { #class = "form-check-label" })
#Html.ValidationMessageFor(model => model.IsSettlementOnHold, "", new { #class = "text-danger" })
</div>
</div>
</div>
<div class="form-group">
#Html.TextAreaFor(model => model.AdditionalNote, 3, 50, new { #class = "form-control", #placeholder = "Any Aditional Note" })
#Html.ValidationMessageFor(model => model.AdditionalNote, "", new { #class = "text-danger" })
</div>
<div class="form-group">
#*<input type="submit" value="Submit" class="btn btn-default" id="btnSelfServiceRequestSubmit"/>*#
<button type="submit"
class="btn btn-dark"
id="btnSelfServiceRequestSubmit"
#*data-toggle="modal"
data-target="#modalEntityDetail"
data-url="#Url.Action("_CodePrompt", "ExternalSelfServiceRequest")"*#>
Submit
</button>
<button type="reset"
class="btn btn-warning">
Reset
</button>
</div>
#if (Model.RequiresApproval.Equals("Yes"))
{
<div class="alert alert-info" role="alert">
For security verification purpose you will be required to access your JKSB Registered Mobile, there will
be a verification code sent to it.
</div>
}
</div>
}
Appreciate any help.
You can separate your "form-check" div like this;
<div class="form-control">
<div class="form-check form-check-inline">
<input checked="checked" class="form-check-input" id="rbIsSettlementOnHold_No" name="IsSettlementOnHold" type="radio" value="No">
<label for="rbIsSettlementOnHold_No" class="form-check-label"> Standard</label>
</div>
<div class="form-check form-check-inline">
<input class="form-check-input" id="rbIsSettlementOnHold_Yes" name="IsSettlementOnHold" type="radio" value="Yes">
<label for="rbIsSettlementOnHold_Yes" class="form-check-label"> On Request </label>
</div>
</div>
And using "form-check-inline" class will be provide you a horizontal alignment.
I hope this helps.

How to convert a static html into razor view in asp.net mvc?

I have the following simple bootstrap form:
#{
ViewBag.Title = "Register";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h3>Register</h3>
<br>
<form action="/User/Register">
<div class="form-group row">
<label class="col-sm-2 col-md-1 col-form-label">Name</label>
<div class="col-sm-10 col-md-2">
<input name="name" type="text" class="form-control" placeholder="Enter Name">
</div>
</div>
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-md-1 col-form-label">Email</label>
<div class="col-sm-10 col-md-2">
<input name="email" type="email" class="form-control" placeholder="Enter email">
</div>
</div>
<div class="form-group row">
<label for="staticEmail" class="col-sm-2 col-md-1 col-form-label">MAC</label>
<div class="col-sm-10 col-md-2 positioned_relative">
<span class="add-new-icon glyphicon glyphicon-plus-sign" id="add_mac"> </span>
<input type="text" class="form-control" id="mac_addr" placeholder="Enter MAC">
</div>
</div>
<div class="form-group row new_mac_wrapper">
<div class="col-md-offset-3">
<div class="new_mac_container">
</div>
</div>
</div>
<button type="submit" class="btn btn-primary col-sm-offset-1">Register</button>
</form>
I want to convert this into razor view as follows:
#model RouterManagement.Models.UserViewModel
#{
ViewBag.Title = "Register";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<h3 class="pull-left">Register</h3> <br />
#using (Html.BeginForm())
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
<div class="form-group row">
#Html.LabelFor(model => model.Name, htmlAttributes: new { #class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-2">
#Html.EditorFor(model => model.Name, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.Name, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.Email, htmlAttributes: new { #class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-2">
#Html.EditorFor(model => model.Email, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.Email, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.Password, htmlAttributes: new { #class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-2">
#Html.EditorFor(model => model.Password, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
#Html.LabelFor(model => model.Mac, htmlAttributes: new { #class = "col-sm-2 col-md-1 col-form-label" })
<div class="col-sm-10 col-md-2">
#Html.EditorFor(model => model.Mac, new { htmlAttributes = new { #class = "form-control" } })
#Html.ValidationMessageFor(model => model.Mac, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-sm-10 col-md-2">
<input type="submit" value="Create" class="btn btn-primary col-sm-offset-1" />
</div>
</div>
}
<div>
#Html.ActionLink("Back to List", "Index")
</div>
And for this conversion I get the following rendered HTML:
<form action="/Users/Register" method="post"><input name="__RequestVerificationToken" type="hidden" value="IZ_dvCy7QtB1VsoqQGh6x_Yzr1DME9V6LjKs1Fi8KL6KxOoKNNvFlH6mdw8yD4xIj-LKaUXFsNZndDTeHOa8xCVZPdu7b8qNXeL05IdIyiQ1"> <div class="form-group row">
<label class="col-sm-2 col-md-1 col-form-label" for="Name">Name</label>
<div class="col-sm-10 col-md-2">
<input class="form-control text-box single-line" id="Name" name="Name" type="text" value="">
<span class="field-validation-valid text-danger" data-valmsg-for="Name" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-md-1 col-form-label" for="Email">Email</label>
<div class="col-sm-10 col-md-2">
<input class="form-control text-box single-line" id="Email" name="Email" type="text" value="">
<span class="field-validation-valid text-danger" data-valmsg-for="Email" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-md-1 col-form-label" for="Password">Password</label>
<div class="col-sm-10 col-md-2">
<input class="form-control text-box single-line" id="Password" name="Password" type="text" value="">
<span class="field-validation-valid text-danger" data-valmsg-for="Password" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 col-md-1 col-form-label" for="Mac">Mac</label>
<div class="col-sm-10 col-md-2">
<span class="field-validation-valid text-danger" data-valmsg-for="Mac" data-valmsg-replace="true"></span>
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-sm-10 col-md-2">
<input type="submit" value="Create" class="btn btn-primary col-sm-offset-1">
</div>
</div>
</form>
This is approximately close to my static html. If you pay a deep attention you can see some additional html generated in case of razor view. I am okay with this additional html but why my design has been broken. I checked for css and js files. All are okay, but there is something related to razor conversion only. Any Idea?
N.S: I am switching from PHP to ASP. So I am apologizing if my question is not standard to ask here. Thanks for your time.
In brief - this two HTML's are not the same.
They differ in a few things:
- in original bootstrap form, you have inputs for Name, Email, and Mac - in generated you have Name, Email, Password, and Mac.
Then in original, each input tag is wrapped in div with class = "form-group row" in generated only first input has these, and the rest have only "form-group". Then in original inside MAC input group, you have div with class="col-sm-10 col-md-2 positioned_relative" and in original, there is no such thing.
Also in original, you have div with class="form-group row new_mac_wrapper" and in the generated code there is none.
I will not go further into details but as you can see you have two different code - hard to tell what is breaking things without a chance to see the whole project.
However, the suggestion is to start little by little - start with just one field (Name) in original and on generated code.
See the differences and only when there is none keep up adding and comparing one field at the time.

I have MVC Error Parser Error

first time use MVC and i want to change the position and want to change the logo. after this i write the #using
the error is Parser Error what happened ?
#using Angga.Models
#model LoginViewModel
#{ ViewBag.Title = "Log in"; }
<div class="col-sm-4">
</div>
<div class="col-sm-4">
#using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-horizontal", role = "form"})) { #Html.AntiForgeryToken()
<div class="page animsition vertical-align text-center" data-animsition-in="fade-in" data-animsition-out="fade-out" style="animation-duration: 800ms; opacity: 1;">
<div class="page-content vertical-align-middle">
<div class="panel">
<div class="panel-body">
<div class="brand">
<img class="brand-img" src="~/image/logo-blue.png" alt="..." />
<h2 class="brand-text font-size-18">MYLOYALTY</h2>
</div>
<form method="post" action="customer_search.php" autocomplete="off">
#Html.ValidationSummary(true, "", new {#class = "text-danger"})
<div class="form-group form-material floating">
<!-- Untuk Email-->
<!-- <label class="floating-label">Email</label> -->
<div class="form-group">
#Html.LabelFor(m => m.Email) #Html.TextBoxFor(m => m.Email, new { #class = "form-control" }) #Html.ValidationMessageFor(m => m.Email, "", new { #class = "text-danger" })
</div>
#*
<input style="margin-left: auto; margin-right: auto; text-align: center;" type="email" class="form-control" name="email" />*#
</div>
<!-- Untuk Password-->
<div class="form-group form-material floating">
#Html.LabelFor(m => m.Password) #Html.PasswordFor(m => m.Password, new {#class= "form-control"}) #Html.ValidationMessageFor(m => m.Password, "", new { #class = "text-danger"}) #*
<input style="margin-left: auto; margin-right: auto; text-align: center;" type="password" class="form-control" name="password" />*#
</div>
<div class="form-group clearfix">
<div class="checkbox-custom checkbox-inline checkbox-primary checkbox-lg pull-left">
<input type="checkbox" id="inputCheckbox" name="remember" />
<label for="inputCheckbox">Remember me</label>
</div>
</div>
<button style="" class="btn btn-primary btn-block btn-lg" onclick="location.href='#Url.Action(" About ")'">Sign in</button>
</form>
</div>
</div>
}
<footer class="page-copyright page-copyright-inverse">
<p>© 2016. All RIGHT RESERVED.</p>
</footer>
</div>
</div>
</div>
<div class="col-sm-4">
</div>
#section Scripts { #Scripts.Render("~/bundles/jqueryval") }
and this my code :D, the error is Parser Error
The Error is
enter image description here
this arise for your nested form
because you already introduce a form in html div
#using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-horizontal", role = "form"})) { #Html.AntiForgeryToken()
........
and you try to introduce another form in the same form
<form method="post" action="customer_search.php" autocomplete="off">
......

Formatting on form not enough room for labels

I am new to mvc I am having some styling issues here with my form for some reason. I dont appear to have enough room for my text labels and its being squashed full screen.
I do not no if begin form would mess with the styling or not but having a real issue here.
<div class="col-xs-12 col-sm-12">
#using (Html.BeginForm("Step1", "Forms", FormMethod.Post, new { #class = "form-horizontal" }))
<h4>Health Check - Personal Details</h4>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("First Name", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="firstName" name="firstName" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Middle Name", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmiddleName" name="txtMiddleName" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Surname", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtLastName" name="txtLastName" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Saluation", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtSaluation" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Aliases", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtAliases" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Maritial Status", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Address 1", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtAddress1" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Address 2", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtAddress2" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("City", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Post Code", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("County", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtCounty" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Country", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Date Of Birth", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
#(Html.Kendo().DatePicker()
.Name("datepicker"))
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Home Tel No", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Home Work No", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtmStatus" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Fax No", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtFaxNo" name="txtFaxNo" class="form-control" type="text" />
</div>
</div>
<div class="form-group">
<div class="col-xs-3 text-right">
#Html.Label("Mobile No", new { #class = "col-md-2 control-label" })
</div>
<div class="col-xs-9">
<input id="txtMobile" name="txtMobile" class="form-control" type="text" />
</div>
</div>
<button type="submit" id="btnSave">Save</button>
Answer 1 works ok for full screen but when mobile it shows as this
#Html.Label("Surname", new { #class = "col-md-2 control-label" })
renders
<label class="col-md-2 control-label">Surname</label>
So, you are nesting a .col-md-2 inside a .col-xs-3.
If you see form-horizontal docs
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label">Email</label>
<div class="col-sm-10">
<input type="email" class="form-control" id="inputEmail3" placeholder="Email">
</div>
</div>
So you can try something like this for each .form-group
<div class="form-group">
#Html.Label("Surname", new { #class = "col-md-3 control-label" })
<div class="col-md-9">
<input id="txtLastName" name="txtLastName" class="form-control" type="text" />
</div>
</div>

is their anyway to return nothing in actionResult not to refresh that page if validations raised

this is my actionResult
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Payment(PaymentViewModel payment, string returnUrl)
{
PaymentModel paymentModel = new PaymentModel();
if (ModelState.IsValid)
{
CreditCardDetailsModel creditCardDetailsModel = new CreditCardDetailsModel();
creditCardDetailsModel.SecurityId = payment.SecurityId;
creditCardDetailsModel.ExpiryDate = payment.Month + payment.Year;
creditCardDetailsModel.CardNumber = payment.CardNumber;
paymentModel.CreditCardDetails = creditCardDetailsModel;
TempData["model"] = paymentModel;
return RedirectToAction("Payment");
}
var query = from state in ModelState.Values
from error in state.Errors
select error.ErrorMessage;
var errorList = query.ToList();
TempData["ErrorMessages"] = errorList;
ViewBag.MonthList = new SelectList(new[] { "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12" });
return new EmptyResult();
}
This is my partialView
#model Centra.Web.ViewModels.PaymentViewModel #using (Html.BeginForm("Payment", "Flight", FormMethod.Post,null))
{
#Html.AntiForgeryToken()
<div class="row space-form traveller-form">
<div class="col-lg-12">
<div class="col-lg-3 row">
<div class="fomr-group text-right">
<label>Credit Card No</label>
</div>
</div>
<div class="col-lg-8">
<div class="fomr-group col-lg-5 cardDetails">
#Html.TextBoxFor(p => p.CardNumber, new { #class = "form-control" })
</div>
<div ng-if="creditCardError == true" class="fomr-group col-lg-2 cardDetails">
<label>Please enter valid card number</label>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-3 row">
<div class="fomr-group text-right">
<label>Expiry Date</label>
</div>
</div>
<div class="col-lg-8">
<div class="fomr-group col-lg-2 cardDetails ">
#Html.DropDownListFor(m=>m.Month, (SelectList)ViewBag.MonthList)
</div>
<div class="fomr-group col-lg-3 cardDetails row">
#Html.DropDownListFor(p => p.Year, Enumerable.Range(DateTime.Now.Year, 20)
.Select(x => new SelectListItem
{
Text = x.ToString(),
Value = x.ToString()
}
), new { #class = "form-control" })
</div>
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-3 row">
<div class="fomr-group text-right">
<label>Name on card</label>
</div>
</div>
<div class="col-lg-8">
<div class="fomr-group col-lg-5 cardDetails">
#Html.TextBoxFor(p => p.NameOnCard, new { #class = "form-control" })
</div>
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-3 row">
<div class="fomr-group text-right">
<label>CVV</label>
</div>
</div>
<div class="col-lg-8">
<div class="fomr-group col-lg-2 cardDetails">
#Html.TextBoxFor(p => p.SecurityId, new { #maxlength = "4", #class = "form-control", #placeholder = "CVV" })
</div>
<div class="fomr-group col-lg-5 cardDetails TotalPrice">
<label>The 3 digit number printed on the back of card</label>
</div>
</div>
</div>
<div class="col-lg-12 terms-conditions">
<div class="col-sm-11 col-lg-offset-1">
<div class="checkbox">
<label>
#* #Html.CheckBox("paymentCheckbox", new { #onclick = "function-to-open-dialog()" })*#
<input type="checkbox" id="paymentCheckbox" ng-model="paymentCheckbox">
I understand and agree to the rules and notifications of this fare, the booking privacy policy and the terms & conditions Centra Travels.
</label>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-2 row">
<div class="fomr-group text-right">
</div>
</div>
<div class="col-lg-9 row">
<div class="fomr-group TotalPrice">
<label>
<h3>$ 36,613</h3>
<span>(Total inclusive all taxes)</span>
</label>
</div>
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-2 row">
<div class="fomr-group text-right">
</div>
</div>
<div class="col-lg-2 row">
<div class="fomr-group text-right col-lg-2">
#*<button type="submit" ng-disabled="!paymentCheckbox" ng-click="Payment(PaymentDetails)" class="btn btn-info makePaymentbtn">Make a Payment</button>*#
<button type="submit" ng-disabled="!paymentCheckbox" class="btn btn-info makePaymentbtn">Make a Payment</button>
</div>
#Html.Hidden("returnUrl", this.Request.RawUrl)
</div>
</div>
</div>
}
And other partialPages are not in mvcRazor formate their are in angular, so when i redirect to specific view(FlighBooking) //FlightBooking is my mainView in that multiple partial views are their, it is rending the FlightBooking View with but angular partialview are losing its states, so i tried by returning as return new EmptyResult(); but the page state is loosing, what should i do?
I want to bee on that same page without loosing its state if validations fails
If you don't want to refresh your page after go to action, you should use #Ajax.BeginForm instead #Html.BeginForm. There are a lot of tutorials on the internet.

Resources