Skip to main content

Posts

Singleton-Design patterns- step by step explanation with simple examples for beginners to intermediate

Singleton- Design patterns - Software  Design patterns - Design patterns in C#.NET - easy simple example what is  Singleton  design pattern In software engineering, the singleton pattern is a software design pattern that restricts the instantiation of a class to one "single" instance. This is useful when exactly one object is needed to coordinate actions across the system. The term comes from the mathematical concept of a singleton. using System; namespace SingleTonnDesignPatternExample {     class Logger     {         private static Logger logger;         private Logger()         {         }         public static Logger GetInstance()         {             if (logger == null)             {                 logger = new Logger();             }             return logger;         }     }     class Program     {         static void Main(string[] args)         {             Logger logg = Logger.GetInstance();         }     } }

MVC DataAnnotations - Validations

using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; using System.Linq; using System.Web; namespace MVCWebApp.Models {     public class UserRegistrationModel     {         [Required(ErrorMessage = "Please Enter Name e.g. John Doe")]         [StringLength(30, MinimumLength = 3)]         public string Name { get; set; }         [Required(ErrorMessage = "Please Provide Gender")]         public bool Gender { get; set; }         [Range(18, 60)]         public string Age { get; set; }         [Required]         [DataType(DataType.Date)]         [Display(Name = "Date Of Birth")]         public DateTime? DateOfBirth { get; set; }         [StringLength(200)]         public string Address { get; set; }         [StringLength(35)]         public string City { get; set; }         [Required(ErrorMessage = "Please Enter Mobile No")]         [Display(Name = "Mobile")]         [St

Asp.net MVC Grrid with search add update and delete

CRUD Operations Using jqGrid In ASP.NET MVC 1. Create a new MVC Project and give the name for your project. To create a new MVC  project, Click File > New > Project or press CTRL + SHIFT + N.     2. Select MVC as a project Template with Individual Authentication.     3. Now for creating the table into the database using Code First Approach, I am creating a folder with name "Entities". For creating the folder inside the project right click on the folder and click on Add then click on  New Folder .     Now give the name for the folder as "Entities" .   4.  Add a class inside  Entities  folder with Name "StudentMaster.cs". You can follow the below figure to add class:   Now one dialog box will be open give the name for that class as "StudentMaster.cs".     5. Now write the following code into "StudentMaster". using  System;   using  System.Collections.Generic;   using  System.ComponentModel.D