Skip to main content

Posts

Kendo UI :How do you make a kendo datepicker do date validation for a minimum date?

<!DOCTYPE html> <html> <head> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.common.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.rtl.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.default.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.dataviz.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.dataviz.default.min.css" rel="stylesheet" type="text/css" /> <link href="http://cdn.kendostatic.com/2013.3.1119/styles/kendo.mobile.all.min.css" rel="stylesheet" type="text/css" /> <script src=...

MVC: Fix: The version of SQL Server in use does not support datatype 'datetime2'.

This message appeared today after posting a new build to our ASP.NET 4 web app: The version of SQL Server in use does not support datatype 'datetime2'. The DBA doesn’t use datetime2 because it’s new in SQL Server 2008 and the site runs on 2005.  It turns out that Entity Framework 4 somehow got the idea to use  SQL Server 2008. The fix was to edit the .edmx file in an XML editor and set the   ProviderManifestToken="2005 " instead of 2008. (You need to rebuild.) Here’s how the line should look against SQL Server 2005: <Schema Namespace="OfficeBookDBModel.Store" Alias="Self" Provider="System.Data.SqlClient" ProviderManifestToken="2005" xmlns:store=http://schemas.microsoft.com/ado/2007/12/edm/EntityStoreSchemaGenerator xmlns="http://schemas.microsoft.com/ado/2009/02/edm/ssdl">    I’m not sure where EF got the notion to ‘upgrade’ to SQL Server 2008. Perhaps it detected something locally.  I’ve jus...

MVC: Exact string Custom Validation

Model Property [Display(Name = "SchoolName CustomValidator(ValidName='MySchool')")] [ExactString(ValidName = "MySchool", ErrorMessage = "The Input Name must exactly equal by Valid Name")] public string SchoolName { get; set; } Custom Validation class public class ExactStringAttribute : ValidationAttribute ,IClientValidatable     {         public string ValidName { get; set; }         public override bool IsValid(object value)         {             if (value != null)                 if (value.ToString() == ValidName)                     return true;             return false;         }         public IEnumerable<ModelClientValidationRule> GetClientValidationRules(ModelMetadata metadata, ControllerContext c...

Could not load type 'System.ServiceModel.Activation.HttpModule' from assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3. 0 . 0 . 0 , Culture=neutral, PublicKeyToken=b77a5c561934e089′. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.TypeLoadException: Could not load type ‘System.ServiceModel.Activation.HttpModule’ from assembly ‘System.ServiceModel, Version=3. 0 . 0 . 0 , Culture=neutral, PublicKeyToken=b77a5c561934e089′. Solution : You need to run aspnet_regiis.exe for both .NET Framework v2 and v4. This can be accomplished by using the –iru parameters when running aspnet_regiis.exe as follows: aspnet_regiis.exe -iru start-> Run--> c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\aspnet_regiis.exe -iru

Kendo UI File Uploading Client Side Validation

In Kendo UI async file uploading there is no option to make some client side validation like: No of files you can upload at a time Size of the file Extension of your uploading file               So, how we can achieve this ? So, to know that see the javascript code snippet below. I am going to explain that. $ ( '#selectedFiles-edit-win' ). kendoUpload ({ multiple : true , localization : { select : 'Select File(s)' }, async : { saveUrl : "/CFCS/AjaxFactory.cfc?method=uploadFile" , removeUrl : "/CFCS/AjaxFactory.cfc?method=cancelUploadedFile" , autoUpload : true }, select : function ( e ) { var files = e . files ; if ( files . length > 10 ) { alert ( "Maximum 10 files can be uploaded at a time." ); e . preventDefault (); return false ; }   for ( var fileCntr = 0 ; fileCntr < files . length ; fileCntr ++ ) { if ( files [ fileCntr ]. s...

MVC: How to display validation messages with javascript alert window?

For the unobtrusive client validation you could subscribe to the  showErrors  callback and display the errors the way you want ( alert  in your case): ( function ( $ ) { $ . validator . setDefaults ({ onsubmit : true , onkeyup : false , onfocusout : false , showErrors : function ( errorMap , errorList ) { if ( errorList . length > 0 ) { var errors = errorList . map ( function ( element ) { return element . message ; }). join ( '\r\n' ); alert ( errors ); } } }); })( jQuery ); In order to display server side errors with  alert  on the client you shouldn't be using the  @Html.ValidationSummary( true )  helper because this helper outputs the errors directly in the view and you said that you don't have enough place. So you could emit javascript dynamically when there are errors and...

How to create index in sql

SQL - Retrieve data pagewise CREATE TABLE tblContact ( Id INT IDENTITY(1,1)       , FirstName NVARCHAR(10)       , LastName NVARCHAR(10)       , Address NVARCHAR(10)       , Tel_no NVARCHAR(10) )  GO CREATE PROCEDURE [dbo].[GetAllContacts]  @searchVal VARCHAR(500),  @page INT = NULL,  @perPage INT = NULL AS DECLARE @Start INT, @End INT SET @page = ISNULL(@page, 1) SET @perPage = ISNULL(@perPage, 10) SET @start = CASE WHEN @page = 1 THEN 0 ELSE (@page - 1) * @perPage END + 1 SET @end =  CASE WHEN @page = 1 THEN @perPage ELSE (@page * @perPage) END ;WITH [Contacts] AS ( SELECT [Id]  , [FirstName]  , [LastName]  , [Address]  , [Tel_no]  , ROW_NUMBER( ) OVER (ORDER BY LastName) AS [Index] FROM    [tblContact] WHERE ([FirstName] LIKE ('%'+ @searchVal +'%') OR [LastName]  LI...