inputs not filling entire width of bootstrap column in mvc view - asp.net-mvc

I am having the hardest time of getting my inputs to fill the max width of a bootstrap column in a MVC 5 project. I added a view and added the layout page to the view (nothing fancy, just the normal layout page that comes with a typical MVC project). If you run the snippet I provided, my inputs are filling the given width of the bootstrap column, but when I run this code in my app, its not filling the width of the column.
Is there anything in particular that would cause my screenshot to look like it does and not how it is in my snippet?
here is the screenshot ( the multicolored columns are for a point of reference for me )
.max-size {
width: 100% !important;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="container">
<div class="form-horizontal">
<div class="row">
<div class="col-md-12">
<div class="col-md-1" style="background:blue">col-md-1</div>
<div class="col-md-1" style="background:red">col-md-1</div>
<div class="col-md-1" style="background:purple">col-md-1</div>
<div class="col-md-1" style="background:yellow">col-md-1</div>
<div class="col-md-1" style="background:green">col-md-1</div>
<div class="col-md-1" style="background:orange">col-md-1</div>
<div class="col-md-1" style="background:blue">col-md-1</div>
<div class="col-md-1" style="background:red">col-md-1</div>
<div class="col-md-1" style="background:purple">col-md-1</div>
<div class="col-md-1" style="background:yellow">col-md-1</div>
<div class="col-md-1" style="background:green">col-md-1</div>
<div class="col-md-1" style="background:orange">col-md-1</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
ABC
</div>
<div class="col-md-6">
<div class="row max-size">
<div class="col-md-12">
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" style="width:100%;" placeholder="Department" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" placeholder="Department" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" placeholder="Department" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" placeholder="Department" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" placeholder="Department" />
</div>
</div>
<div class="form-group">
<div class="col-md-12">
<input class="form-control max-size" placeholder="Department" />
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<div class="col-md-5">
<div class="btn btn-block btn-danger">
<center>Cancel</center>
</div>
</div>
<div class="col-md-5">
<div class="btn btn-block btn-success">
<center>Submit</center>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-3">
CBA
</div>
</div>
</div>
</div>

they can't go full width cause their parent have a col-md-6 put 12 and it will work
i mean here
<div class="col-md-6">
<div class="row max-size">
<div class="col-md-12">
also try to read more about nesting here is a link http://getbootstrap.com/2.3.2/scaffolding.html

Related

keep content inside a Card from flowing outside of it

I am using the grid system to layout out three filters and a button. The button is partially outside the card. I want it to break to a new row if it can't fit.
I've tried playing with the col-lg- and col-auto, but can't seem to get that right combination.
<div class="row g-1">
<div class="col-lg-6 mb-3">
<div class="card shadow">
<div class="card-body">
<h3>Activity</h3>
<div class="row g-1 align-items-end">
<div class="col-lg-5 mb-3">
<label class="form-label">Location</label>
<asp:DropDownList ID="ctLocation" runat="server" CssClass="form-select"></asp:DropDownList>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">Start Date</label>
<asp:TextBox ID="ctStartDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">End Date</label>
<asp:TextBox ID="ctEndDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-lg-1 mb-3">
<input type="button" id="ctRefresh" class="btn btn-outline-primary" value="Refresh" />
</div>
</div>
<hr />
<div class="mt-3">
<canvas id="dailyTraffic" height="100"></canvas>
</div>
</div>
</div>
</div>
The solution: add col-auto to the last column (i.e., the one which contains the button).
The class col-auto will push the button to a new line if there's not enough space for it.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="row g-1">
<div class="col-lg-6 mb-3">
<div class="card shadow">
<div class="card-body">
<h3>Activity</h3>
<div class="row g-1 align-items-end">
<div class="col-lg-5 mb-3">
<label class="form-label">Location</label>
<asp:DropDownList ID="ctLocation" runat="server" CssClass="form-select"></asp:DropDownList>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">Start Date</label>
<asp:TextBox ID="ctStartDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">End Date</label>
<asp:TextBox ID="ctEndDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-auto mb-3">
<input type="button" id="ctRefresh" class="btn btn-outline-primary" value="Refresh" />
</div>
</div>
<hr />
<div class="mt-3">
<canvas id="dailyTraffic" height="100"></canvas>
</div>
</div>
</div>
</div>
</div>
Let's say you change "Location" column from col-lg-5 to col-lg-3. Now there's enough space for the button to be in the same line.
<link href="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/bootstrap#5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
<div class="row g-1">
<div class="col-lg-6 mb-3">
<div class="card shadow">
<div class="card-body">
<h3>Activity</h3>
<div class="row g-1 align-items-end">
<div class="col-lg-3 mb-3">
<label class="form-label">Location</label>
<asp:DropDownList ID="ctLocation" runat="server" CssClass="form-select"></asp:DropDownList>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">Start Date</label>
<asp:TextBox ID="ctStartDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-lg-3 mb-3">
<label class="form-label">End Date</label>
<asp:TextBox ID="ctEndDate" runat="server" CssClass="form-control datepicker"></asp:TextBox>
</div>
<div class="col-auto mb-3">
<input type="button" id="ctRefresh" class="btn btn-outline-primary" value="Refresh" />
</div>
</div>
<hr />
<div class="mt-3">
<canvas id="dailyTraffic" height="100"></canvas>
</div>
</div>
</div>
</div>
</div>

FormCollection inputs on action method have null values

I am trying to get values of form inputs on action method.
MVC View
#using (Html.BeginForm("Report", "Home"))
{
<div class="common_input Volunteer_input">
<div class="row">
<div class="col-sm-12">
<label for="firstName">Reporter:</label>
<div class="select_option_one">
<input type="text" id="ReporterCountries" class="ct-select2 ReporterCountriesList" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Partner:</label>
<div class="select_option_one">
<input type="text" name="PartnersCountries" id="PartnersCountries" class="ct-select2 CountryList" />
</div>
</div>
</div>
<h3>Comparators</h3>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Partner:</label>
<div class="select_option_one">
<input type="text" name="CompareCountryList" id="CompareCountryList" class="ct-select2 CountryList" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<label for="firstName">Rank Growth:</label>
<div class="select_option_one">
<input type="text" name="RankGrowth" id="RankGrowth" class="ct-select2 RankGrowth" />
</div>
</div>
</div>
<div class="row">
<div class="col-sm-12">
<div class="sub_submit">
<button type="submit" class="common_btn hvr-sweep-to-bottom">View<i class="fa fa-long-arrow-right"></i></button>
</div>
</div>
</div>
</div>
}
Action Method for Home Controller
public ActionResult Report(FormCollection form)
{
ViewData["ReporterCountries"] = Request.Form["ReporterCountries"];;
return RedirectToAction("Index","data");
}
When I try to retrieve the values of input on action controller I am receving all the control on the view but values are coming as null.

JQuery Multi-step form in asp.net mvc

I have a multistep form wizard that go through seven(7) steps.
image
Controllers:
private RegistrationEntities db = new RegistrationEntities();
public ActionResult Index()
{
return View();
}
View:
<div class="title_right">
<div class="col-md-5 col-sm-5 col-xs-12 form-group pull-right top_search">
<div class="input-group">
<input type="text" class="form-control" placeholder="Search for...">
<span class="input-group-btn">
<button class="btn btn-default" type="button">Go!</button>
</span>
</div>
</div>
</div>
</div>
<div class="clearfix"></div>
<div class="row">
<div class="col-md-12 col-sm-12 col-xs-12">
<div class="x_panel">
<div class="x_title">
<h2>Contractors <small>Pre-Registration</small></h2>
<ul class="nav navbar-right panel_toolbox">
<li>
<a class="collapse-link"><i class="fa fa-chevron-up"></i></a>
</li>
<li class="dropdown">
<i class="fa fa-wrench"></i>
<ul class="dropdown-menu" role="menu">
<li>
Settings 1
</li>
<li>
Settings 2
</li>
</ul>
</li>
<li>
<a class="close-link"><i class="fa fa-close"></i></a>
</li>
</ul>
<div class="clearfix"></div>
</div>
<div class="x_content">
<p>Kindly Follow the Procedures for the Pre-Registration Process.</p>
<div id="wizard" class="form_wizard wizard_horizontal">
<ul class="wizard_steps">
<li>
<a href="#step-1">
<span class="step_no">1</span>
<span class="step_descr">
Step 1<br />
<small>Step 1: Ownership Confirmation</small>
</span>
</a>
</li>
<li>
<a href="#step-2">
<span class="step_no">2</span>
<span class="step_descr">
Step 2<br />
<small>Step 2: RC Number</small>
</span>
</a>
</li>
<li>
<a href="#step-3">
<span class="step_no">3</span>
<span class="step_descr">
Step 3<br />
<small>Step 3: Company Name</small>
</span>
</a>
</li>
<li>
<a href="#step-4">
<span class="step_no">4</span>
<span class="step_descr">
Step 4<br />
<small>Step 4: TIN Number/Company Details</small>
</span>
</a>
</li>
<li>
<a href="#step-5">
<span class="step_no">5</span>
<span class="step_descr">
Step 5<br />
<small>Step 5: Company's Email</small>
</span>
</a>
</li>
<li>
<a href="#step-6">
<span class="step_no">6</span>
<span class="step_descr">
Step 6<br />
<small>Step 6: Other Company Details</small>
</span>
</a>
</li>
<li>
<a href="#step-7">
<span class="step_no">7</span>
<span class="step_descr">
Step 7<br />
<small>Step 7: Captcha</small>
</span>
</a>
</li>
</ul>
<div id="step-1">
<form class="form-horizontal form-label-left">
<div class="form-group">
<div class="col-lg-12">
<div class="col-lg-3">
<div class="form-group">
</div>
</div>
<div class="col-lg-6">
<div class="form-group">
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 1, new { #class = "DoPopup", id = "Foreign Company", value = "" }) Foreign Company
</div>
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 2, new { #class = "DoPopup", id = "Foreign Owned Nigerian Company", value = "" }) Foreign Owned Nigerian Company
</div>
<div class="radio">
#Html.RadioButtonFor(m => m.OWNERSHIP_STRUCTURE, 3, new { #class = "DoPopup", id = "Nigerian Company", value = "" }) Nigerian Company
</div>
</div>
</div>
<div class="col-lg-3">
<div class="form-group">
</div>
</div>
</div>
</div>
</form>
</div>
<div id="step-2">
#*<h2 class="StepTitle">Step 2 Content</h2>*#
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.RC_NUMBER, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.RC_NUMBER, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.RC_NUMBER)
</div>
</div>
</div>
</form>
</div>
<div id="step-3">
#*<h2 class="StepTitle">Step 3 Content</h2>*#
<form class="form-horizontal form-label-left">
<div class="form-group">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.COMPANY_NAME, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_NAME, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_NAME)
</div>
</div>
</div>
</div>
</form>
</div>
<div id="step-5">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
#Html.LabelFor(model => model.COMPANY_CONTACT_EMAIL, new { #class = "col-lg-2 control-label" })
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_CONTACT_EMAIL, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_CONTACT_EMAIL)
</div>
</div>
</div>
</form>
</div>
<div id="step-6">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="form-group">
<div class="col-lg-2">
Alternative E-mail
</div>
<div class="col-lg-9">
#Html.TextBoxFor(model => model.COMPANY_CONTACT_ALTERNATIVE_EMAIL, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.COMPANY_CONTACT_ALTERNATIVE_EMAIL)
</div>
</div>
</div>
<div class="col-lg-12">
<div class="form-group">
<div class="col-lg-2">
Website
</div>
<div class="col-lg-9">
#Html.TextBoxFor(model => model.WEBSITE, new { #class = "form-control" })
#Html.ValidationMessageFor(model => model.WEBSITE)
</div>
</div>
</div>
<h3>Login Details</h3>
<hr />
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-2">
Username
</div>
<div class="col-lg-8">
#*<i class="glyphicon glyphicon-user"></i>*#
<input class="form-control input-lg" name="MERGE0" id="email" type="email" placeholder="Email address" required>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-2">
Password
</div>
<div class="col-lg-8">
#*<i class="glyphicon glyphicon-user"></i>*#
<input class="form-control input-lg" name="MERGE1" id="password" type="password" placeholder="Password" required>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
</form>
</div>
<div id="step-7">
<form class="form-horizontal form-label-left">
<div class="col-lg-12">
<div class="col-lg-1">
</div>
<div class="form-group">
<div class="col-lg-10">
#Html.MathCaptcha()
#* #Html.Captcha(3)*#
<br />
<p class="Error"> #ViewBag.ErrMessage </p>
</div>
</div>
<div class="col-lg-1">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</section>
}
<!-- jQuery Smart Wizard -->
<script>
$(document).ready(function () {
$('#wizard').smartWizard();
$('#wizard_verticle').smartWizard({
transitionEffect: 'slide'
});
$('.buttonNext').addClass('btn btn-success');
$('.buttonPrevious').addClass('btn btn-primary');
$('.buttonFinish').addClass('btn btn-default');
});
</script>
<!-- /jQuery Smart Wizard -->
The questions are:
How I I validate each step to make sure values are entered befor going to the next step
After completing the 7 steps, how do I valid that the values are entered properly before it saves.
After completing the 7th step, I clicked on the Finish button, no record was saved into the CONTRACTORS table
In step2, when RC_NUMBER is entered, it should check if it already exists. It should use it to populate COMPANY_NAME in step3, but if it doesnt exist, it should allow the user to enter COMPANY_NAME in step3
After completing the whole steps and Finish button is clicked, it should redirect to welcome model using ActionResult Welcome
Please check the answers to your questions below:
1.) jQuery SmartWizard allows us to add onLeaveStep:leaveAStepCallback field while declaring. leaveAStepCallback is the function that will be called when you click on the next button. You can implement your validation logic in this function. Please go through this URL to get the complete idea.
2.) jQuery SmartWizard also allows us to add onFinish:onFinishCallback field while declaring. In this case onFinishCallback function will be called after all the steps are completed. You can check here if all the inputs are valid and then submit the form. You must have got the idea if you had gone through the link in answer 1.
3.) You need to further elaborate why the details were not saved in DB? Is your controller action getting called? If yes, check your DB save logic to further find the issue as this is not the issue of SmartWizard.
4.) As I mentioned in the step 1 that bind a callback function to be called when next button is clicked. In this function, you can get the step number by using context.fromStep. After that you can make an ajax call to server to check if the value already exist. Implement your custom logic as required.
5.) If you are submitting form using $('form').submit(), you can redirect custom view from the controller after succesful operation. If you are making an ajax call, redirect to another controller in sucess function of ajax call.

Angular 2 components tree

I'm developing my first application with Angular 2 and I have installed Augury plugin for Google Chrome, in order to help me debug the code.
Here's the components tree and graph:
This is the HTML template of my custom component (DocumentsList):
<div class="container-fluid" style="margin-top: 10px">
<div class="table-row header">
<div class="column index">#</div>
<div class="wrapper attributes">
<div class="wrapper title-comment-module-reporter">
<div class="wrapper title-comment">
<div class="column title">Title</div>
<div class="column comment">Comment</div>
</div>
<div class="wrapper module-reporter">
<div class="column module">Module</div>
<div class="column reporter">Reporter</div>
</div>
</div>
<div class="wrapper status-owner-severity">
<div class="wrapper status-owner">
<div class="column status">Status</div>
<div class="column owner">Owner</div>
</div>
<div class="column severity">Severity</div>
</div>
</div>
<div class="wrapper icons">
<div title="Watch" class="column watch">
<span class="glyphicon glyphicon-eye-open"></span>
</div>
<div title="Add comment" class="column add-comment">
<span class="glyphicon glyphicon-comment"></span>
</div>
</div>
<div class="wrapper dates">
<div class="column date">Created</div>
<div class="column date">Updated</div>
<div class="column date">Due</div>
</div>
</div>
<div *ngFor="let document of docs" class="table-row">
<div class="column index">{{document.id}}</div>
<div class="wrapper attributes">
<div class="wrapper title-comment-module-reporter">
<div class="wrapper title-comment">
<div class="column title">{{document.title}}</div>
<div class="column comment">{{document.comment}}</div>
</div>
<div class="wrapper module-reporter">
<div class="column module">{{document.module}}</div>
<div class="column reporter">{{document.reporter}}</div>
</div>
</div>
<div class="wrapper status-owner-severity">
<div class="wrapper status-owner">
<div class="column status"><span class="label" [ngClass]="{'Open': 'label-primary', 'In Progress': 'label-success'}[document.status]">{{document.status}}</span></div>
<div class="column owner">{{document.owner}}</div>
</div>
<div class="column severity high">{document.severity}}</div>
</div>
</div>
<div class="wrapper icons">
<div class="column watch"><span class="glyphicon glyphicon-eye-open" [class.active]="document.watched"></span></div>
<div class="column add-comment"><span class="glyphicon glyphicon-comment" [class.active]="document.commented"></span></div>
</div>
<div class="wrapper dates">
<div class="column date">{{document.created}}</div>
<div class="column date">{{document.updated}}</div>
<div class="column date">{{document.due}}</div>
</div>
</div>
</div>
Since the span in the graph is child of a div in which there is a *ngFor directive, shouldn't it be displayed in the graph as the parent of the span?
I think the graph should've looked like this (images created with Paint)
Short answer, yes. It makes sense.

Unobtrusive ajax - View being fully replaced by partial view

I have searched multiple examples and have tried several things to get this to work properly. Currently I am trying to get a div to be replaced by using an Ajax.HtmlLink pointing to a PartialViewResult method.
I have tried
Checking network and javascript consoles to make sure my .js are all being loaded
Unbundling the stock jqueryval bundle and including the scripts manually
Double checked I didn't have another DOM element with the same update target Id
Checked my ajaxoptions to ensure everything was correct
I know unobtrusive is working because my Email duplicate remote validation check is working.
I will now show some screen shots of my debugging process
Here is what the page looks like prior to ajax load
My goal is to replace the container on the right that is currently holding email, name, and zipcode values
Here is the result##
This is what my view code looks like
<div class="container">
<br />
<br />
<div class="row">
<div class="col-sm-3">
<div class="sidebar-account">
<div class="row ">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">My Account</div>
<div class="panel-body">
<ul class="nav">
<li>
<a class="active" href="account_dashboard.html">Me</a>
</li>
<li>
#Ajax.ActionLink("Alerts", "ManageAlerts", null, new AjaxOptions
{
HttpMethod = "GET",
UpdateTargetId = "ajax-update",
InsertionMode = InsertionMode.Replace,
OnBegin = "ajaxBegin",
OnFailure = "ajaxFail",
OnComplete = "ajaxComplete",
OnSuccess = "ajaxSuccess"
}, new { #class = "active" })
</li>
<li>
<a class="active" href="account_account.html">Linked Accounts</a>
</li>
<li>
<a class="active" href="account_ads.html">Manage ads</a>
</li>
<li>
<a class="active" href="account_ad_create.html">Create new ad</a>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="row hidden-xs">
<div class="col-lg-12">
<div class="well">
<div class="row ">
<div class="col-lg-3">
<img src="css/images/icons/Crest.png" width="45" />
</div>
<div class="col-lg-9">
<h4 style="margin-top: 0">Increase visibility</h4>
<p>Don't forget to 'bump' your listing to gain more visibility</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-sm-9">
<div id="ajax-update">
#Html.Partial("_ManageUserAccount", Model)
</div>
</div>
<br />
</div>
Partial View Code##
<div id="fadein-div">
<div class="panel panel-default">
<div class="panel-heading">#Model.Username : Alerts</div>
<div class="panel-body">
<br />
<div class="row">
<div class="col-sm-12">
<p><span style="font-weight:bold">Change your alerts!</span></p>
</div>
</div>
<br />
#using (Html.BeginForm("ManageAlerts", "Account", FormMethod.Post, new { #class = "form-vertical", role = "form" }))
{
#Html.AntiForgeryToken()
<fieldset>
<div class="row">
<div class="col-sm-12 ">
<div class="form-group">
<div class="row">
<div class="col-sm-2">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailAlertsOn) #Html.LabelFor(P => P.EmailAlertsOn)
</div>
</div>
</div>
</div>
<div id="control-div">
<div class="form-group">
<h3>Email alert options</h3>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnNewMessageOn) #Html.LabelFor(P => P.EmailOnNewMessageOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnNewMessageOn)
</div>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnReplyOn) #Html.LabelFor(P => P.EmailOnReplyOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnReplyOn)
</div>
</div>
<div class="form-group">
<div class="checkbox">
#Html.CheckBoxFor(P => P.EmailOnAccountUpdateOn) #Html.LabelFor(P => P.EmailOnAccountUpdateOn)
</div>
<div class="text-danger">
#Html.ValidationMessageFor(P => P.EmailOnAccountUpdateOn)
</div>
</div>
</div>
<br />
<button type="submit" class="btn btn-primary">Save details</button>
</div>
</div>
</fieldset>
}
</div>
</div>
And finally, controller code##
[HttpGet]
public PartialViewResult ManageAlerts()
{
var user = UserManager.FindById(Guid.Parse(User.Identity.GetUserId()));
Models.Account.ManageAlertsViewModel vm = new ManageAlertsViewModel();
vm.Username = user.UserName;
vm.EmailAlertsOn = user.EmailAlertsOn;
vm.EmailOnAccountUpdateOn = user.EmailOnAccountUpdateOn;
vm.EmailOnNewMessageOn = user.EmailOnNewMessageOn;
vm.EmailOnReplyOn = user.EmailOnReplyOn;
return PartialView("_ManageAlerts", vm);
}
<!-- js library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.0/jquery-ui.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/bootstrap.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/jquery.icheck.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/waypoints.min.js"></script>
<!-- authenty js -->
<script src="~/Themes/Authenticity%20Forms/Authenty/js/authenty.js"></script>
<!-- preview scripts -->
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/jquery.malihu.PageScroll2id.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/jquery.address-1.6.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/scrollTo.min.js"></script>
<script src="~/Themes/Authenticity%20Forms/Authenty/js/preview/init.js"></script>
#Scripts.Render("~/bundles/jqueryval")

Resources