Monday 26 November 2018

Data Annotation in ASP NET MVC C# || Code First Approach Entity Framewor...





using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.ComponentModel.DataAnnotations;

using System.ComponentModel.DataAnnotations.Schema;





namespace WebApplication1.Models

{

    [Table("tbl_user")]

    public class User

    {

        [Key]

        public int UserId { get; set; }





        [Display(Name="Name")]

        [Required(ErrorMessage="*")]

        [StringLength(50,ErrorMessage="Name should contain Atmost 50 characters")]

        [MinLength(3,ErrorMessage="Name should contain Atleast 3 characters")]

        [RegularExpression("^[a-z -']+$",ErrorMessage="Invalid Name")]

        public string Username { get; set; }





        [Display(Name = "Email")]

        [Required(ErrorMessage = "*")]

        [StringLength(50, ErrorMessage = "Email should contain Atmost 50 characters")]

        [MinLength(15, ErrorMessage = "Name should contain Atleast 15 characters")]

        [RegularExpression(@"^([\w\.\-]+)@([\w\-]+)((\.(\w){2,3})+)$", ErrorMessage = "Invalid Email")]

        public string UserEmail { get; set; }



        [Display(Name = "Date of Birth")]

        [Required(ErrorMessage = "*")]

        [DataType(DataType.Date)]

        public string Userdob { get; set; }





        [Display(Name = "Password")]

        [Required(ErrorMessage = "*")]

        [StringLength(50, ErrorMessage = "Password should contain Atmost 50 characters")]

        [MinLength(6, ErrorMessage = "Password should contain Atleast  6 characters")]

     

        public string userpassword { get; set; }



        [Display(Name = "Confrim Password")]

        [Required(ErrorMessage = "*")]

        [Compare("userpassword",ErrorMessage="Password Does not match...")]

        public string usercpassword { get; set; }





   

   

   

   

   

    }



}

More Directives in Angular JS || Basics of Angular JS || Part-3





<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

    <title></title>

    <link href="Content/bootstrap.min.css" rel="stylesheet" />

    <link href="Content/bootstrap.css" rel="stylesheet" />

    <script src="Scripts/angular.js"></script>

    <script src="Scripts/angular.min.js"></script>

</head>

<body ng-app="">



    <div ng-init="Checked=true;Checked1=true;Checked2=true;Checked3=true">



        Header<input type="checkbox" ng-model="Checked" />

        Section<input type="checkbox" ng-model="Checked1" />

        Footer<input type="checkbox" ng-model="Checked2" />

        Read Only<input type="checkbox" ng-model="Checked3" />

        <header ng-if="Checked" style="background-color:#b6ff00;width:100%;height:200px; margin:0 auto;"></header>



        <section ng-if="Checked1" style="background-color: #ffd800;width:100%;height:700px; margin:0 auto;">



            <div class="container">



                <input type="text" ng-readonly="Checked3" class="form-control" />

                <br />

                <input type="text" ng-disabled="Checked3" class="form-control" />



                <br />



                <div class="container">

                    <div ng-init="employee=[{ID:1001,name:'ali',Department:'IT'} ,{ID:1002,name:'AHMED',Department:'MANAGER'},{ID:1003,name:'BASIT',Department:'HR'},{ID:1004,name:'salman',Department:'Software'}]">



                        <table class="table table-responsive">

                            <thead>

                                <tr>

                                    <th>ID</th>

                                    <th>NAME</th>

                                    <th>DEPARTMENT</th>



                                </tr>



                            </thead>

                            <tbody>

                                <tr ng-repeat="x in employee">

                                    <td>{{x.ID}}</td>

                                    <td>{{x.name}}</td>

                                    <td>{{x.Department}}</td>



                                </tr>





                            </tbody>







                        </table>











                    </div>

                    </div>















            </div>

        </section>



        <footer ng-if="Checked2" style="background-color:#ff0000;width:100%;height:200px; margin:0 auto;"></footer>













    </div>











</body>

</html>


Pass Dynamically Added Html Table Records List To Controller In Asp.net MVC

Controller Code: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using ...