Posts

Showing posts from August, 2019

Server Side Validation In MVC using ModelState

Server Side Validation In MVC using ModelState using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.ComponentModel.DataAnnotations; namespace ServerSideValidationInMVC.Models {     public class Student     {         [Required(ErrorMessage = "Name is Requirde")]         public string Name { get; set; }         [Required(ErrorMessage = "Email is Requirde")]         [RegularExpression(@"^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}" +                             @"\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\" +                             @".)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$",                             ErrorMessage = "Email is ...

How to call stored procedure in MVC Application

How to call stored procedure in MVC Application public int UpdateFinalOutcome( bool isDeathCertificate, bool isCornerReferralComplete) { int retVal = 0; SqlCommand dbCommand = new SqlCommand ( "usp_UpsertFinalOutcome" , connection);             try             {                 dbCommand.CommandType = CommandType .StoredProcedure;                 dbCommand.Parameters.AddWithValue( "@isDeathCertificate" , isDeathCertificate);                 dbCommand.Parameters.AddWithValue( "@isCornerReferralComplete" , isCornerReferralComplete); retVal = dbCommand.ExecuteNonQuery(); catch ( Exception ex)      ...