Showing posts from October, 2015

Common Asp.Net Tips and Tricks 3

IntroductionThis is a series articles on ASP.NET Tips and Tricks. Under my previous article Common ASP.Net Tips and Tricks,we learned configuration tips and tricks. The article explained common exceptions we encounter while development and best practices for code implementation.
Tips and Tricks

LINQ to Entities does not recognize ToString

Sometimes LINQ to Entities does not recognize the method "System.String ToString()" and this method cannot be translated into a store expression.


This type of exception frequently occurs when we are working with LINQ or Entity Framework.

For example:
var result=dc.Tests.Where(i=>i.status==status.ToString()).FirstOrDefault();  
According to the preceding syntax, when we convert “status.ToString()”, in the where condition the exception "Expression not found such method in SQL" occurs where the condition returns an IQueryable result. So if we convert the result to IEnumerable, then the preceding type of exception never occurs.


Validate CKEditor using jQuery validate

Introduction In this article we learn about how to validate CKEditor control using jquery validate

Prerequisite. Below JavaScript library are used to validate CKEditor control.
Jquery-1.11.1.jsJquery.Vaidate.jsDescriptionWhen we configure CKEditor control in our html page it render in Iframe so jquery validate library fails to check weather this control is empty or not and we face issue while validating this control. Let’s see example:
HTML: <form> <textarea id="txtDemo1" name="txtDemo1"></textarea> <textarea id="txtDemo2" name="txtDemo2"></textarea> <input type="submit" value="submit"> </form>
Let’s assume we have configured CKEditor for both text area control and both fields are required in system. For validation we have implemented following validation for both control as shown below:

$("form").validate({ ignore: [], rules: { txtDemo1: { ckrequired: true /…