Sunday 21 September 2014

MVC-5 [Model-View-Controller]

Basic-1
What is MVC ?
Ans: ASP.Net is a framework for building scalable,standard based web-applications using well establish design pattern including the power of asp.net and .net framework.

1) Validation in MVC (Client and server side)-->
https://www.youtube.com/watch?v=N3vH0fLqU6A
https://www.youtube.com/watch?feature=player_detailpage&v=mfezkbOpXPA#t=346
RULE-1:MODEL
 this is for server and client both required annotations
Add a model class and write below code on it- use namespace must as below
using System.ComponentModel.DataAnnotations;

RULE-2:VIEW  (Comment in View-   @* my comment Line Here *@)
@model (Project_Name).Models.(model class_NAme)
@model mvcCRUD.Models.ModClass2
@using(Html.BeginForm())
{
@Html.LabelFor(m=>m.UserName)
@Html.TextBoxFor(m=>m.UserName)
@Html.ValidationMessageFor(m=>m.UserName)
}

<input type="submit" id="btnInsert" name="btnInsert" value="INSERT"/>

RULE-3:Controlle
using System.(Project_Name).Models;
using mvcCRUD.Models;
RULE-4:  It is bydefault true so no need to set.
WEb.Config:
<appSettings>
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>

********************
Q1. What is Data Annotation???
A-It is a mechanism ,we can use it to feed metadata into application and framework will display and render html markup.Data aanotation are attributes which are used to perform server side validation as well as client side validations.



 

No comments:

Post a Comment

FAQ--(3- Tier Project)

BACK   https://meeraacademy.com/3-tier-architecture-example-in-asp-net-c/ 1. Presentation Layer (UI – User Interface Layer) 2. Busine...