Showing posts with label Errors. Show all posts
Showing posts with label Errors. Show all posts

Monday, 28 January 2019

This article gives you the solutions for erros while writing coding in C#.NET

Hi Readers,

In this article, Giving you the solutions for our day to day facing problems/errors while coding in C#.NET.

Note: This article is going to keep on updating erros with solutions in different scenarios either it may runtime/compiletime.


1. Compilation error : Too many characters in character literal
    Reason: In C#, Adding single quote to multiple characters (Strings) Ex: 'Hello Nuthan!'
    Solution: To fix this, "Hello Nuthan!"

2. Compilation error : The name 'console' does not exist in the current context
    Reason: Either no namespace is included or case-sensitive or spelling mistake
   Soultion: For this error, We changed from console to Console and this class is available in under System Namespace.




Happy Coding :)
Yours TechiNuthan

Tuesday, 30 December 2014

Compare Validator creating at codebehind in c#

Compare Validator is one of the validator control in ASP.NET validators. With this,we can use to compare the controls with the help of operator and type attributes.

Listing all Types of CompareValidator

  • Currency
  • Date
  • Double
  • Integer
  • String

Listing all Operators of CompareValidator

  • DateTypeCheck
  • Equal
  • GreaterThan
  • GreaterThanEqual
  • NotEqual
  • LessThan
  • LessThanEqual

Now we can see the below example code created in code behind and used for validating the fields,

            CompareValidator cmpval = new CompareValidator();
            cmpval.ControlToCompare = FromDate.ClientID;
            cmpval.ControlToValidate = ToDate.ClientID;
            cmpval.Type = ValidationDataType.Date;
            cmpval.Operator = ValidationCompareOperator.GreaterThanEqual;
            cmpval.ForeColor = Color.Red;
            cmpval.Display = ValidatorDisplay.Dynamic;
            cmpval.ErrorMessage = "From Date should be smaller than the To Date";
            plholdervalidmessage.Controls.Add(cmpval);

Adding the above example control to Placeholder

That's it,

Happy Coding:)