First Install asp.net mvc3 software
Creating a new MVC application using the Razor view engine. Go to vstd.net
Click on file
Click on new
Click on project
Select asp.net.mvc 3 web application
Type application name
Click on ok Select the project template as internet application Select the view engine as Razor Click on ok When we create Razor application there do not we any deference Only deference is with in the view all view pages are created . CSHTML extension . where very view page will contain plain HTML code. So that Rendering will be much more minimized reduced. --.Razor syntax will take 3 techniques to write
in general syntax of Razor is for single line blocks
@ {statement 1 ;} @ {statement 2 ;}
EX :- 1. @ {var a = 10;} @ {var b = 20.5} @ {var c = ‘satya’}
@ {double b = 20.5} @ {String c = ‘satya’} We use the following syntax for multiple blocks
Syntax:
@ { statement 1 ;} statement 2; }
Ex :-
Var b = 20.5; Var c = ‘satya’ }
@ {double b = 20.5} @ {String c = ‘satya’}
Go to solution explorer
Select Home folder
Click with RM button
Click on Add
Click on view
Type the view name as (Sample)
De active check box use view (or) Layout
Click on add
A new view page is created with the name sample. HTML
Go to source
Write the following code. On the top of page
@ { layout = null; } @ { Var a =10; Var b = “satya”; Var c = “20.5” }
<body>
<h2> satya technologies </h2>
<div>
<p> value of a a is :- @ a </p>
<p> value of a b is :- @ b </p>
<p> value of a c is :- @ c </p>
</div> </body>
Learn ASP.net by Tekslate - Fastest growing sector in the industry. Explore Online "ASP.net Training" and course is aligned with industry needs & developed by industry veterans. Tekslate will turn you into ASP.net Expert.
Public action result sample ()
{
Return view ();
}
Go to global .aspx
↓
Change the action name as sample and check and run the application
--> Create a new view page (Sample)
↓
Write the following code for Razor syntax and design
@ { layout = null;
Int num 1, num2 , result = 0;
If (is post)
{
Num 1 = convert to int 32 (Request [“T1”]);
Num 2 = convert to int 32 (Request [“T2”]);
Result = num 1 + num2;
<form .action = “”Method = “post”>
Enter first number
<input type = ‘text’@ “T1”/> <Br>
Enter Second number
<input type = ‘text’@ “T2”/> <Br>
Result is : @ Result
<input type = ‘submit’ id = “B1” value = “Add”/>
</form>
For in-depth understanding click on
You liked the article?
Like : 0
Vote for difficulty
Current difficulty (Avg): Medium
1/15
TekSlate is the best online training provider in delivering world-class IT skills to individuals and corporates from all parts of the globe. We are proven experts in accumulating every need of an IT skills upgrade aspirant and have delivered excellent services. We aim to bring you all the essentials to learn and master new technologies in the market with our articles, blogs, and videos. Build your career success with us, enhancing most in-demand skills in the market.
Stay Updated
Get stories of change makers and innovators from the startup ecosystem in your inbox