Hi Guest

MobileUser

1 HomePage 1 Jobs 1 WalkIn 1Articles  

Cat Exam

 :) Latest Topic
AJAX
VB.NET
SQL Query
UDDI
CLASS
JavaScript Questions
SharePoint Interview
SilverLight
WCF
general knowledge
 ASP.NET
 :) Hot Jobs
 
 :) Latest Articles


  

 
Helmet Star


Can you write down some syntax for Razor in MVC3
Question Posted on 11 May 2012

Home >> DotNet >> MVC >> Can you write down some syntax for Razor in MVC3




Below i have given some syntax of razor as well as some comparison with the old technlogies used before Razor
(1)First for datetime
  (i)New Razor code for datatime
    @DateTime.Now
  (ii)Old code for datetime
    < % =DateTime.Now%>


(2)Syntax for ForEach loop
  @foreach (string obj in obj)
  {
    @obj
  }


(3)Code for multiple lines we will add @ at first row
  @{
    List objlst = new List ();
    objlst.Add("dotnet");
    objlst.Add("java");
    objlst.Add("php");
    objlst.Add("sql");
}


(4)To HTML display with Razor
  @{
    var link = "< a href='http://www.getproductprice.com'>Click here< /a>";
  }@link;
  Here in above code you will get output as < a href='http://www.getproductprice.com' >Click here


(5)ANd to display link we use below code
  @{
    var link = "< a href='http://www.getproductprice.com' >Click here< /a>";
  @Html.Raw(link);
  Now with above code will will get link Click Here only
0
0



 
 Input Your Comments Or suggestions(If Any)
 Name
 Email(optional)
 Comments


Other Important Questions
How to create Razor enable application in MVC3
Can you write down some syntax for Razor in MVC3
Basic diagram of MVC
Different MVC version with there features
Could not load type System.Web.Mvc.ViewPage in asp.net MVC2






 
Top Searches:asp net questions vb net questions sql query uddl questions class javascript Questions sharepoint interview questions and concept silverlight questions and concept wcf questions beans general knowledge ajax questions
PHP | Biztalk | Testing | SAP | HR |