May 6, 2013

IF condtion for MVC4 with Razor engine in the view

@model MyMvcApp.Models.Customer@{
Layout = null;}

<!DOCTYPE html><html><
head><meta name="viewport" content="width=device-width" /><title>DisplayCustomer</title></
head><
body><div>The customer id is @Model.Code
<br />The customer name is @Model.Name
<br />@if(Model.Amount >100){

@(
"The customer is top customer")}

else
{
@("The customer is normal customer")}



</div></
body></
html>

Model is the class name is Customer that contain property Amount 

if u pass 110 from the controller then the out put will be "The customer is top customer"

if u pass 99 from the controller then the out put will be "The customer is normal customer"

@ this is razor symbol in MVC

Thanks & Regards

Vamsi Krishna Reddy

No comments:

Post a Comment