© 2013 - Showing: DBContext DBSet< Holding > SignalR and knockout extenders for column type validation.
If you cannot see a table of data
- HTML Rendering: SignalR To KnockOut template data-bind
- Could Not Load Records.
- Hub Server: DB Initializing ...
- Hub Server: DB Getting ...
- Hub Server: Calling Client Loading ...
- Hub Server: Calling Client Completed.
[Image of Test] I would be rather keen on knowing (a) which of the six messages is on your screen (b) your OS (c) browser version.
OS: Windows 8 | Windows Server 2008R2 | Windows Server 2012 ? Recent Browsers: Explorer10 | Chrome | Opera ?
Please note, the observable and subscribe combine with extenders to report validation failure.
The DataAnnotations [Required] {KeyName (nvarchar(max),not null)} and other types {decimal,bigint,datetime}
are protected through the Entity Framework.
In the sample above try a Grid Edit like: [] [x] [123.c45][x0123][01-Jan-2000], individually those three fields
do not call Update on keystroke because they are in error,
if with those three errors in place, provide a valid flag (any character) then Update is called.
It seems at that point Entity Framework just rejects such bad data. (my SignalR Hub pushes the exception message in its catch).
<script src="../Scripts/jquery-3.2.1.min.js"></script>
<script src="../Scripts/jquery-ui-1.12.1.min.js"></script>
<script src="../Scripts/jquery.unobtrusive-ajax.js"></script>
Above is what I have included, I do not know whether "jquery.unobtrusive-ajax.js" is needed
Either
<script src="../Scripts/jquery.validate.js"></script>
<script src="../Scripts/jquery.validate.unobtrusive.js"></script>
Legacy package, jQuery.Validation.Unobtrusive is now included in the 'Microsoft.jQuery.Unobtrusive.Validation' package.
Or
$("input[type='datetime']").datepicker({ dateFormat: "dd-M-yy" });
I prefer a datepicker along with my own validation especially as I favour KnockOut.
However it is possible to do this:
BundleConfig.cs needs this [, "~/Scripts/jquery.validate*"] via WebGrease (WG.Exe) and create a new "min" file.
in jquery.validate(.min).js, visit the
link above scroll to the bottom of the page and enter a date.
[DisplayFormat(ApplyFormatInEditMode=true, DataFormatString = "{0:dd-MMM-yyyy}")]
System.ComponentModel.DataAnnotations
@Html.DisplayFor(model => model.Birthday)
@Html.EditorFor(model => model.Birthday)
means I get my date Format with vanilla Razor syntax.
@Html.ValidationMessageFor(model => model.Birthday)
Since this produces "data-val" for a date it seems a data-val-format="dd-M-yy"
would help.
ko.bindingHandlers.dateString
value( moment(element.value, 'DD-MMM-YYYY').toDate() );
element.value = moment(valueUnwrapped).format('DD-MMM-YYYY');
<input data-bind="dateString: Birthday, valueUpdate: 'afterkeydown'" type="datetime" />
Above is an extract from a KnockOut bindingHandler and its usage with
"moment.js" providing the translations
that replaced
<input data-bind="value: Birthday, valueUpdate: 'afterkeydown'" type="datetime" />
which displayed dates as "2011-12-06T15:05"
Opera seems to want "2011-12-06T15:05Z"
http://amsul.ca "pickadate.js" I rather like this compared to jQuery.datepicker()
http://www.coolite.com "date.js" is cool, it uses intelligence to guess your date as you type.
See : http://msdn.microsoft.com/en-us/vs2010trainingcourse_aspnetmvccustomvalidation_topic5.aspx
From Database To POCO: http://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838