Select dropdown not displaying properly in the cshtml View - asp.net-mvc

The dropdown on the image below do not display properly. I want the dropdown to cover the length of the Modal Popup. The Button on the page fire properly I have no issue with my Controller. Any help to resolve this issue will be appreciated
View Code
<a class="btn w-xs btn-primary" data-toggle="modal" data-target=".bootstrapmodal"><i class="fa fa-book" aria-hidden="true"></i><span id="#ViewBag.Group"> Add New Member</span></a>
<div class="modal fade bootstrapmodal ">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button data-dismiss="modal" class="close"><span>×</span></button>
<div class=" modal-title"><h3>Add User to Active Directory Group #ViewBag.Group </h3></div>
</div>
<div class="modal-body">
<div class="content">
#using (Html.BeginForm("AddNewUser", "ActiveDirectoryMember", FormMethod.Post, new { enctype = "multipart/form-data", id = "addUser" }))
{
#Html.ValidationSummary(true, "", new { #class = "text-danger" })
#Html.AntiForgeryToken()
<div class="panel ">
<div class="panel-body ">
<div class="form-horizontal">
<input type="hidden" name="groupName" value="#ViewBag.Group" />
<div class="form-group">
#Html.Label("Technician", new { #class = "control-label col-md-2 required" })
<div class="input-group">
<div class="col-md-8">
<select id="userId" name="userId" class="form-control s2-search-box2">
<option value="">Click search for a staff member</option>
</select>
</div>
</div>
</div>
<div class="form-group">
<div class="col-md-2">
</div>
<div class="col-md-2">
<button type="submit" class="btn btn-success" id="addUser">
<i class="fa fa-plus-circle"></i>
Add New User
</button>
</div>
</div>
</div>
</div>
</div>
}
</div>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal">
<i class="fa fa-ban"></i>
Cancel
</button>
</div>
</div>
</div>
</div>

Related

How to keep selected tab as active after button click

Below is my code
In Update Tab when I select an email id - after return view it set again add tab as active (coz it was set as active by default).
How to set the update tab as active after selecting email id - any idea .
<ul class="nav nav-tabs">
<li role ='presentation' class="active">Add</li>
<li role ='presentation'>Update</li>
<li role ='presentation'>Delete</li>
<li role ='presentation'>Menu 3</li>
</ul>
<div class="tab-content">
<div id="Add" class="tab-pane active">
#using (Html.BeginForm("Add", "Admin"))
{
<div class="container container-fluid">
<br />
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-user-o" aria-hidden="true"></i>
</div>
#Html.TextBoxFor(m => m.user_name, new { #class = "form-control", #placeholder = "User Name", #required = "true" })
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-address-card-o" aria-hidden="true"></i>
</div>
#Html.TextBoxFor(m => m.full_name, new { #class = "form-control", #placeholder = "Full Name", #required = "true" })
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-inbox" aria-hidden="true"></i>
</div>
#Html.TextBoxFor(m => m.user_email, new { #class = "form-control", #placeholder = "Email id", #required = "true" })
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-lock" aria-hidden="true"></i>
</div>
#Html.TextBoxFor(m => m.password, new { #class = "form-control", #placeholder = "Password", #required = "true" })
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-universal-access fa-spin" aria-hidden="true"></i>
</div>
#Html.DropDownListFor(m => m.role, ViewBag.role as IEnumerable<SelectListItem>, new { #class = "form-control" })
</div>
</div>
</div>
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<button type="submit" class="btn btn-success btn-sm">
<i class="fa fa-check-square-o" aria-hidden="true"></i>
Add
</button>
</div>
</div>
</div>
}
</div>
<div id="Update" class="tab-pane">
#using (Html.BeginForm("Load_data", "Admin")) {
<div class="container container-fluid">
<br />
<div class="row">
<div class="col-lg-offset-1 col-lg-5">
<div class="input-group">
<div class="input-group-addon">
<i class="fa fa-users" aria-hidden="true"></i>
</div>
#Html.DropDownListFor(m => m.user_email, ViewBag.user_email as IEnumerable<SelectListItem>, new { #class = "form-control",#onchange= "this.form.submit();" })
</div>
</div>
</div>
</div>
}
<div id="Details">
//Details of selected email id will be shown here
</div>
</div>
<div id="Delete" class="tab-pane">
</div>
<div id="menu3" class="tab-pane">
</div>
</div>
Basically you can't do that, because your page is refreshing. If you want that then you need to do it asynchronously. I mean you need to use #Ajax.BeginForm or jquery/ajax.
If you don't want to do it asynchronously, then there is a work around way.
So while calling to your action method after selecting an email from your Update tab, assign a value in a ViewBag.
For example, in your action method,
{
//Rest code
ViewBag.TabValue = "Update";
//Rest code
}
Now you can keep this value in a hidden field. For example, in your view,
<input type="hidden" value="#ViewBag.TabValue" id="myTab"/>
So now, in your script, you can check this value and set your tab, like,
<script>
if($('#myTab').val() == "Update")
{
$("#Update").focus(); //You can add a class as active so on...
}
</script>
Hope it helps :)

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.

bootstrap modal with asp.net mvc html helpers

I am trying to implement bootstrap ui modal in asp.net mvc. I created a basic modal which contains a login form.
Issue I am facing here is, when I start using html helpers, styles of the modal form is going really bad. I have attached screenshots below. one screenshot with when I don't use HTML helpers and that's when UI is more clean to view, when I add html helpers, style is going way off.
I have tried pretty much everything I can. I am unable to spot the issue. can someone please have a look at it and throw a light on where I am going wrong.
<div>
#using(Html.BeginForm()){
<div class="modal-header modal-hd-bg">
<button type="button" class="close" ng-click="cancel()">×</button>
<h3 class="modal-title">Login</h3>
</div>
<div class="modal-body">
<form novalidate class="form-horizontal" role="form">
<div class="form-group">
#*<label class="control-label col-sm-3" for="email">Email:</label>*#
#Html.Label("Email:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#* <input type="email" class="form-control" id="email" placeholder="Enter email" ng-model="luser.email">*#
#Html.TextBoxFor(m => m.email, new { #class="form-control", #placeholder="Enter Email", #id="email" })
</div>
</div>
<div class="form-group">
#*<label class="control-label col-sm-3" for="pwd">Password:</label>*#
#Html.Label("Password:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#*<input type="password" class="form-control" id="pwd" placeholder="Enter password" ng-model="luser.pwd">*#
#Html.TextBoxFor(m => m.pwd, new { #class="form-control", #placeholder="Enter password", #id="pwd" })
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary" ng-click="login()">Login</button>
</div>
</div>
</form>
</div>
<div class="modal-footer modal-ft-bg">
<label><u>Don't have an account</u>?</label>
<button class="btn btn-success" ng-click="goToRegister()">Register</button>
</div>
}
</div>
This is when I use #using(Html.BeginForm()) and html helpers
This is when I don't use HTML helpers)
No need for a form outside another form, because the outside form does not take any input. Nothing wrong with the html helpers.
HTML:
<div id="thisModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="gridSystemModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header modal-hd-bg">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h3 class="modal-title" id="gridSystemModalLabel">Login</h3>
</div>
<div class="modal-body">
<form novalidate class="form-horizontal" role="form">
<div class="form-group">
#Html.Label("Email:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#Html.TextBoxFor(m => m.email, new { #class="form-control", placeholder="Enter Email", id="email" }
</div>
</div>
<div class="form-group">
#Html.Label("Password:", new { #class="control-label col-sm-3"})
<div class="col-sm-9">
#Html.PasswordFor(m => m.pwd, new { #class="form-control", placeholder="Enter password", id="pwd" })
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-3 col-sm-9">
<button type="submit" class="btn btn-primary">Login</button>
</div>
</div>
</form>
</div>
<div class="modal-footer modal-ft-bg">
<label><u>Don't have an account</u>?</label>
<button class="btn btn-success">Register</button>
</div>
</div>
</div>
</div>

How can i prevent page refresh (reload) while pressing login button in asp.net mvc identity?

So folks, i just created a _Login partial instead of Login view and rendered that partial view in my _Layout. The partial view is shown in a Modal, until yet everything seems OK! But whenever i just click the Login (Sign In) button the page reloads and nothing happens although i expect an error like the E-mail field cannot be empty or the user does not exist but surprisingly nothing happens and the page refreshes.
Here is the code for the _Login partial.
#model Hire.af.WebUI.Models.LoginViewModel
<div class="modal-body">
<!--Social Media Login Links-->
<div class="form-group row login-socical">
<div class="col-sm-9 col-sm-offset-3">
<div class="button_socical fb">
<i class="fa fa-facebook-square"> </i>
<em class="fa-facebook-square">Login with Facebook</em>
</div>
<div class="button_socical gg">
<i class="fa fa-google-plus"> </i>
<em class="fa-google-plus">Login with Google</em>
</div>
<div class="button_socical linkedin">
<i class="fa fa-linkedin-square"> </i>
<em class="fa-linkedin-square">Login with LinkedIn</em>
</div>
</div>
</div>
<!--Login Form-->
<form class="noo-ajax-login-form form-horizontal">
#using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { #class = "form-horizontal", role = "form" }))
{
#Html.AntiForgeryToken()
<hr />
#Html.ValidationSummary(true, "", new { #class = "col-sm-3" })
<div class="form-group row">
#Html.LabelFor(m => m.Email, new { #class = "col-sm-3 control-label" })
<div class="col-sm-9">
#Html.TextBoxFor(m => m.Email, new { #class = "log form-control", #placeholder="Email OR Username" })
#Html.ValidationMessageFor(m => m.Email, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group row">
#Html.LabelFor(m => m.Password, new { #class = "col-sm-3 control-label" })
<div class="col-sm-9">
#Html.PasswordFor(m => m.Password, new { #class = "pwd form-control", #placeholder="Password" })
#Html.ValidationMessageFor(m => m.Password, "", new { #class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
#Html.CheckBoxFor(m => m.RememberMe)
#Html.LabelFor(m => m.RememberMe)
</div>
</div>
</div>
<!--Remember Me Checkbox-->
<div class="form-actions form-group text-center">
<button type="submit" class="btn btn-primary">Sign In</button>
<div class="login-form-links">
<span><i class="fa fa-question-circle"></i> Forgot Password?</span>
<span>
Don't have an account yet?
<a href="#" class="member-register-link" data-rel="registerModal">
#Html.ActionLink("Register Now", "Register") <i class="fa fa-long-arrow-right"></i>
</a>
</span>
</div>
</div>
#* Enable this once you have account confirmation enabled for password reset functionality
<p>
#Html.ActionLink("Forgot your password?", "ForgotPassword")
</p>*#
}
</form>
</div>
and below is how i rendered this partial in my _Layout.
<div class="memberModalLogin modal fade" id="userloginModal" tabindex="-1" role="dialog" aria-hidden="true">
<div class="modal-dialog modal-member">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
<h4 class="modal-title">Login</h4>
</div>
<!--Login Partial Goes Here-->
#Html.Partial("_Login")
</div>
</div>
</div>
Any help would be appreciated.
You have nested forms which is invalid html and not supported. Remove the outer form from your partial view
<form class="noo-ajax-login-form form-horizontal"> // remove this and its closing tag
#using (Html.BeginForm(....

Grails sign up with Modal Window

I am using grails 2.1.1 and trying to sign up a new user with modal window. My signup modal window's .gsp code is as follows...
....
<!--Start of Registration Modal Page-->
<div id="register" class="modal hide fade" aria-labelledby="modalLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
<i class="icon-remove"></i>
</button>
<h3 id="modalLabel">
Register
</h3>
</div>
<div class="modal-body">
<g:form method="POST">
<div class="controls controls-row">
<div class="span1"></div>
<input type="text" class="span2" placeholder="Full Name" value="${user?.profile?.fullName}">
<div class="span1"></div>
</div>
<div class="controls controls-row">
<div class="span1"></div>
<input type="text" class="span3" placeholder="Email" value="${user?.profile?.email}">
<div class="span1"></div>
</div>
<div class="controls controls-row">
<div class="span1"></div>
<input type="text" class="span3" placeholder="Username" value="${user?.username}">
<div class="span1"></div>
</div>
<div class="controls controls-row">
<div class="span1"></div>
<input type="password" class="span3" placeholder="Password" value="${user?.password}">
<div class="span1"></div>
</div>
<div class="controls controls-row">
<div class="span1"></div>
<input type="text" class="span3" placeholder="Bio" value="${user?.profile?.bio}">
<div class="span1"></div>
</div>
<div class="controls controls-row">
<div class="span1"></div>
<button type="submit" class="span3 btn btn-warning">Create Account</button>
<div class="span1"></div>
</div>
<div class="modal-footer">
<button class="btn btn-danger" data-dismiss="modal" aria-hidden="true">Cancel
</button>
<button class="btn btn-success" type="submit">Register
</button>
</div>
</div>
</div>
</g:form><!--End of Form-->
<!--End of Registration Modal Page-->
My corresponding controller is "user" and I have a customized "register" action there as well. All I want is that when I click Create Account button, the user is registered behind in the database. Is there any way to make it up through modal window form directly?

Resources