Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
Node is saved as draft in My Content >> Draft
  • Razor basic for MVC

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 48
    Comment on it

    Razor engine that is used with MVC is identified by the symbol @.

    Razor engine is used in MVC for generating views and defining the HTML part.

    Single statement block and inline expression

    @{ var message = "Hello,Razor view engine";}
    Message is : @message

    Multi Statement Block

    @{
        var priciple = 100;
        var rate = 12;
        var time = 2;
        var interest = (priciple * rate * time) / 100;
    }
    //Interest of @priciple rupees is @interest for @time years

    Conditional Statement

    @{
    var isValid = true;
    if(isValid)
    {
        It is an if statement in code block
    }
    else
    {
        It is an else statement in code block
    }
    }
    @if(true)
    {
        It is a single if block
    }

    Looping

    @{
        for(var count = 1;count,=3;count++)
        {
            @Count is : @count
        }
               
        string [] nameArray = {"Sandeep","Mandeep","Kuldeep","Pradeep"};
        foreach(var name in nameArray)
        {
            Your Name is : @name
        }
    }

     

    .net

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: