I have a view (refer below code) , but the datetimepicker is stretching , now to removed the stretching. May be this is due to the bootstrap table . Need some guide to display the datetimepicker in the elegant way.
<div class="container">
<div class="clearfix"></div>
#using (Html.BeginForm("Create", "DoctorPayment"))
{
#Html.AntiForgeryToken()
#Html.ValidationSummary(true)
<fieldset>
#*<legend>DoctorPayment</legend>*#
<div class="panel">
<div class="panel-body">
...
<div class="row">
<div class="col-lg-3 pull-left">
<div class="editor-label">
#Html.LabelFor(model => model.PaymentDate)
</div>
</div>
<div class="col-lg-9">
<div class="editor-field">
#Html.EditorFor(model => model.PaymentDate)
#Html.ValidationMessageFor(model => model.PaymentDate)
</div>
</div>
<div class="col-lg-1">
</div>
</div>
<div style="margin-top: 5px"></div>
....
</div>
<p>
<input type="submit" value="Create" />
</p>
</div>
</fieldset>
}
<div>
#Html.ActionLink("Back to List", "Index")
</div>
....
#section Scripts {
#Scripts.Render("~/bundles/jqueryval")
#Styles.Render("~/Content/boostrap")
#Scripts.Render("~/bundles/jqueryui")
#Styles.Render("~/Content/cssjqryUi")
<script type="text/javascript">
$(document).ready(function () {
$('input[type=datetime]').datepicker({
dateFormat: "dd/M/yy",
changeMonth: true,
changeYear: true,
yearRange: "-60:+0"
});
});
$('#PaymentDate').datepicker({
showButtonPanel: false,
beforeShow: function () {
$(".ui-datepicker").css('font-size', 12)
}
});
$("#PaymentDate").click(function () {
$("#ui-datepicker-div")
// BTW, min-width is better:
.css("min-width", $(this).outerWidth() + "px");
});
</script>
}
}
</div>
I have included bootstrap to it.
I believe that you might have overwritten something in css, or added some atributes.
Try this and see if it works.
$("#dropdown").closest("span.k-dropdown").width(400);
If it does, try to add a custom class to the datepicker so that you don't edit all dropdowns.
Also, changing the font size will change the size of the datepicker.
$('#PaymentDate').datepicker({
showButtonPanel: false,
beforeShow: function () {
$(".ui-datepicker").css('font-size', 12)
}
});
$("#PaymentDate").click(function () {
$("#ui-datepicker-div")
.css("max-width", $(this).outerWidth() + "px");
});
Related
I want to use label as used "Static Control" label on that page. However, although I use the same Bootstrap version, I cannot aligned my form controls like that (I want the label is right float, data fields is left float -side by side - and there is a ":" sign between them. Howwver, the result is as shown on the image below. Could you please have a look at my code and inform what is wrong?
The code on that page:
<div class="form-group">
<label class="col-md-3 control-label">Static Control</label>
<div class="col-md-9">
<p class="form-control-static"> email#example.com </p>
</div>
</div>
The code I use on my Razor page:
<div class="form-group">
#Html.LabelFor(m => m.Name, new { #class = "col-md-3 control-label" }):
<div class="col-md-9">
#Html.DisplayFor(m => m.Name, new { #class = "form-control-static" })
</div>
</div>
<br />
<div class="form-group">
#Html.LabelFor(m => m.Surname, new { #class = "col-md-3 control-label" }):
<div class="col-md-9">
#Html.DisplayFor(m => m.Surname, new { #class = "form-control-static" })
</div>
</div>
You have two elements which equal 100% width plus the colon, so it pushes the value down a line. You'll need to just code the label instead of using an HtmlHelper to add the colon. Change it to this:
<div class="form-group">
<label class="col-md-3 control-label">#Model.Name:</label>
<div class="col-md-9">
#Html.DisplayFor(m => m.Name, new { #class = "form-control-static" })
</div>
</div>
Here is the final solution fixed the problem. Thanks a lot for all of your helps...
<style>
.col-sm-3 .control-label {
float: right !important;
margin-top: 0 !important;
}
/*Add colon ( : ) to the end of labels */
.col-sm-3 > label:after {
content: " :";
}
</style>
<div class="form-group">
<div class="col-sm-3">
#Html.LabelFor(m => m.Name, new { #class = "control-label" })
</div>
<div class="col-sm-9">
#Html.DisplayFor(m => m.Name)
</div>
</div>
<br />
<div class="form-group">
<div class="col-sm-3">
#Html.LabelFor(m => m.Surname, new { #class = "control-label" })
</div>
<div class="col-sm-9">
#Html.DisplayFor(m => m.Surname)
</div>
</div>
<br />
index.cshtml
<head>
<meta name="viewport" content="width=device-width" />
<title></title>
<script src="~/Scripts/angular.min.js"></script>
<script src="~/Scripts/angular-route.min.js"></script>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<script src="~/App/App.js"></script>
<script src="~/App/Controllers/FlightCtrl.js"></script>
</head>
<body>
<div id="wrapper">
Hi
#*<resolve-loader></resolve-loader>*#
<div class="nav navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav" >
<li>#Html.ActionLink("Home", "Index", "Home")</li>
<li class="dropdown">
<a>Add Flight</a>
</li>
</ul>
</div>
</div>
</div>
<div ng-view> </div>
</body>
</html>
App.js
var AirReservationApp = angular.module("AirReservationApp", ['ngRoute']);
AirReservationApp.config(['$routeProvider',
function ($routeProvider)
{
$routeProvider.
when('/Admin', { templateUrl: 'App/Views/Flights/AddFlight.htm', controller: 'FlightCtrl' }).
otherwise({
redirectTo: '/Admin'
});
}
]);
AddFlight.html
<div ng-controller="FlightCtrl">
<ng-form name="formFlight">
<div>
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12">
<label class="col-xs-12 col-sm-12 col-md-12 col-lg-12" for="question">Question <span class="mandatory">*</span> </label>
<div class="form-group col-xs-9 col-sm-9 col-md-8 col-lg-8"
<input type="text" name="FlightCode"
ng-required="=true" existnamevalidate valid="YN"
placeholder="Enter Flight Code"
ng-model="CreateFlight.Flight.FlightCode">
<span class="help-block"
Flight code is required.>
</span>
<span class="help-block"
This Flight Code already exists.>
</span>
</div>
</div>
<!--ng-show="isTextType"-->
<div class="row btn-pos-change">
<div class="col-md-12 padding-top-12 btn-blocks">
<div class="form-group">
<button type="button" class="btn btn-success pull-right"
>
{{saveBtnText}}
</button>
</div>
</div>
</div>
</div>
</ng-form>
</div>
FlightCtrl.js
var FlightCtrl = angular.module("FlightCtrlModule", []);
FlightCtrl.controller("FlightCtrl", ["$scope", "$rootScope", "$timeout", "$window", "$route",
function ($scope, $rootScope, $timeout, $window, $route)
{
alert('Hello');
$scope.saveBtnText = "Create";
}]);
The expression {{saveBtnText}} does not show 'Create'. Can any one help me on this.
Try this.
First create the FlightCtrlModule module on top of the AirReservationApp module in the App.js and the inject it to the AirReservationApp module.
App.js
angular.module("FlightCtrlModule", []);
var AirReservationApp = angular.module("AirReservationApp", ['ngRoute', 'FlightCtrlModule']);
AirReservationApp.config(['$routeProvider',
function ($routeProvider) {
$routeProvider.
when('/Admin', { templateUrl: '/home.html', controller: 'FlightCtrl' }).
otherwise({
redirectTo: '/Admin'
});
}
]);
Now attach the FlightCtrl controller to the AirReservationApp module to have access to the FlightCtrlModule module.
FlightCtrl
//var FlightCtrl = angular.module("FlightCtrlModule", []);
AirReservationApp.controller("FlightCtrl", ["$scope", "$rootScope", "$timeout", "$window", "$route",
function ($scope, $rootScope, $timeout, $window, $route) {
alert('Hello');
$scope.saveBtnText = "Create";
}]);
UPDATE
If you want to keep your approach, what you can do is, move the flight controller above the app.js like so:
<script src="~/App/Controllers/FlightCtrl.js"></script>
<script src="~/App/App.js"></script>
And then inject the module FlightCtrlModule to the AirReservationApp module, like so:
var AirReservationApp = angular.module("AirReservationApp", ['ngRoute', 'FlightCtrlModule']);
both way have the same result.
Example Project - Dropbox
I am using ajax.beginform to make an ajax login popup.
Everything works fine the first time, but when I submit a second time (after an error message from model validation) it no longer updates my div with the content but refreshes the page and shows the partial view in a blank page. It's not doing the ajax anymore.
I have included all javascripts needed.
My partial view:
#using (Ajax.BeginForm("Login", "Account", null, new AjaxOptions
{
UpdateTargetId = "login-partial-update",
HttpMethod = "POST",
OnSuccess = "loginSuccess"
}, new { id = "js-form-login" }))
{
<div class="fluid-row-margin">
<div class="cell12">
#Html.TextBoxFor(x => x.Email, new { placeholder = "Email address" })
<div class="errormessage">
#Html.ValidationMessageFor(x => x.Email)
</div>
</div>
</div>
<div class="fluid-row-margin">
<div class="cell12">
#Html.PasswordFor(x => x.Password, new { placeholder = "Password" })
<div class="cell12 errormessage">
#Html.ValidationMessageFor(x => x.Password)
</div>
</div>
</div>
<div class="fluid-row-margin">
<div class="cell1">
#Html.CheckBoxFor(x=>x.RememberMe)
</div>
<div class="cell11">Remember me</div>
</div>
<div class=" errormessage">
#if (Model.HasErrors)
{
<br />#Model.ErrorMessages
}
</div>
}
<script type="text/javascript">
$.validator.unobtrusive.parse("#js-form-login");
</script>
My parent view includes this partial
<div id="login-partial-update">
#Html.Partial("Widgets/Login/_LoginInput", new LoginInputModel())
</div>
All this is happening inside a javascript modal dialog
I'm new Ractive.js user.
I want to make two buttons, cliking on them, the message "allert" appears.
I did as here
Here the body of my page
<body>
<div class="center" id='container'></div>
<script id='template' type='text/ractive'>
<h1><p class="center"> {{logo}} </p></h1>
<p class="center">{{name}}</p>
</script>
<script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script>
</div>
<div class="center" id="footer">
<p class="center" ><font color ="ffffff">Footer</font></p>
</div>
<div class="button1">
<button on-click='activate'>Settings</button>
</div>
<div class="button1">
<button on-click='deactivate'>Reports</button>
</div>
<script>
var ractive = new Ractive({
el: 'container',
template: '#template',
data: {
name: 'spatium',
logo: '\\|/' }
});
</script>
<script>
ractive.on({
activate: function () {
alert( 'Activating!' );
},
deactivate: function () {
alert( 'Deactivating!' );
}
});
</script>
</body>
Nothing happend. Can the problem be in conflict between two scripts?
The buttons must be inside your template:
<script src='http://cdn.ractivejs.org/latest/ractive.min.js'></script>
<div class="center" id='container'></div>
<script id='template' type='text/ractive'>
<h1><p class="center"> {{logo}} </p></h1>
<p class="center">{{name}}</p>
<div class="center" id="footer">
<p class="center" ><font color ="ffffff">Footer</font></p>
</div>
<div class="button1">
<button on-click='activate'>Settings</button>
</div>
<div class="button1">
<button on-click='deactivate'>Reports</button>
</div>
</script>
<script>
var ractive = new Ractive({
el: 'container',
template: '#template',
data: {
name: 'spatium',
logo: '\\|/' }
});
ractive.on({
activate: function () {
alert( 'Activating!' );
},
deactivate: function () {
alert( 'Deactivating!' );
}
});
</script>
This is my code:
<div class="row">
<div class="col-xs-4">
<h2>Some header text</h2>
</div>
<div id="div1" class="col-xs-8">
<div class="pull-right">
#using (Html.BeginForm("ChangePageSizeAction", "myController"))
{
#Html.AntiForgeryToken()
<small>Page Size</small>
#Html.DropDownList("pageSize", null, htmlAttributes: new { #class = "form-control", onchange = "this.form.submit();" })
}
</div>
<div id="div2" class="pull-right" style="padding-right:10px">
#Html.PagedListPager(Model, page => Url.Action("Index", new { page }),
new PagedListRenderOptions()
{
MaximumPageNumbersToDisplay = 3,
DisplayPageCountAndCurrentLocation = true,
PageCountAndCurrentLocationFormat = "Page {0} of {1}",
})
</div>
</div>
</div>
This is the output:
I want to align the PagedListPager to bottom beside the DropDownList like this:
I tried to set div1 style to position:relative and div2 style to position:absolute; bottom:0 but didnĀ“t work.
After Morpheus comment I looked for the difference in his jsfiddle example and mine, so I found an error (margin:0) in my css classes.
So, sorry for the wrong question.