23 September 2012

Razor with MVC 3






               
               @{ var total = 7; }
               @{ var myMessage = "Hello World"; }
               

The value of your account is: @total

The value of myMessage is: @myMessage

@{var greeting = "Welcome to our site!"; var weekDay = DateTime.Now.DayOfWeek; var greetingMessage = greeting + " Today is: " + weekDay; }

The greeting is: @greetingMessage




            @Html.Raw(model.Message)
            @:Model.Message (Not render html as a part of output

         


            
               @foreach (var item in Model)
                {
                    
                        
                            @item.Message
                        
                    
                }

                @for (int i = 0; i < Model.ToList().Count(); i++)
                {
                    @Model.ToList()[i].Age
                }

            


            
             @if (false)
              {
                @Model.Message;
              }
             else if (true)
              {
                @DateTime.Now;
              }
              else
              {
                @DateTime.Now;
              }

          


             
             Razor automatically detect email id
            

ranmal.work@gmail.com




              @@my name will print @my name

          


              
              @*code here *@
              
          


              
             Hello word @ViewBag.Message, How r u?
              
          


              
             @(method)
              
          


              
            Click Me
            Click Me
            


              
            
                
                    @Html.GetResource("label_first", ResourceScreenConstant.YourPage)
                
            
          
          

9 September 2012

Cod First using entity framework with MVC