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

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 45
    Comment on it

    While writing codes in MVC you need to understand that we will have HTML here but we dont have the ASPX

    engine

    For MVC we will have Razor engine for writing HTML

    Simple HTML page looks like this

    <!DOCTYPE html>
    
    <html lang="en">
    <head>
       <meta charset="utf-8" />
        <title>Web Pages Demo</title>
    </head>
    <body>
        <h1>Hello Web Pages</h1>
    </body>
    </html> 

    If we add Razor code into it .

    <!DOCTYPE html>
    
    <html lang="en">
    <head>
         <meta charset="utf-8" />
         <title>Web Pages Demo</title>
    </head>
    <body>
         <h1>Hello Web Pages</h1>
         <p>The time is @DateTime.Now</p>
    </body>
    </html> 

    You need to understand for Razor engine @ is always used

    <!-- Single statement block -->
    @{ var myMessage = "Hello World"; }
    
    <!-- Inline expression or variable -->
    <p>The value of myMessage is: @myMessage</p>
    
    <!-- Multi-statement block -->
    @{
    var greeting = "Welcome to our site!";
    var weekDay = DateTime.Now.DayOfWeek;
    var greetingMessage = greeting + " Today is: " + weekDay;
    }
    <p>The greeting is: @greetingMessage</p> 

     

    .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: