RAZOR SYNTAX IN C#

Posted on Updated on

RAZOR SYNTAX IN C#

Razor is a basic programming sentence structure for inserting server code in pages. Razor grammar depends on the ASP.NET structure, the part of the Microsoft.NET Framework that is particularly
intended for making web applications. The Razor grammar gives all of you the force of ASP.NET, yet is utilizing a rearranged sentence structure that is less demanding to learn in case you’re an amateur, and makes you more profitable in case you’re a specialist. Razor website pages can be portrayed as HTML pages with two sorts of substance: HTML substance and Razor code. At the point when the server peruses the page, it runs the Razor code to begin with, before it sends the HTML page to the program. The code that is executed on the server can perform assignments that is impossible in the program, for instance getting to a server database. Server code can make dynamic HTML content on the fly, before it is sent to the program. Seen from the program, the HTML created by server code is the same than static HTML content. ASP.NET website pages with Razor linguistic structure have the extraordinary record augmentation cshtml (Razor utilizing C#) or vbhtml (Razor utilizing VB).

WORKING WITH OBJECTS

Server coding regularly includes objects.

The “DateTime” article is an ordinary implicit ASP.NET object, yet questions can likewise act naturally characterized, a site page, a content box, a document, a database record, and so on. Items may have techniques they can perform. A database record may have a “Spare” strategy, a picture item may have a “Turn”technique, an email article may have a "Send" strategy, et cetera. Protests likewise have properties that depict their qualities. A database record may have a FirstName and a LastName property (amongst others).

The ASP.NET DateTime object has a Now property (composed as DateTime.Now), and the Now property has a Day property (composed as DateTime.Now.Day).

The case underneath demonstrates to get to a few properties of the DateTime object:

<table border=”1″>

<tr>

<th width=”100px”>Name</th>

<td width=”100px”>Value</td>

</tr>

<tr>

<td>Day</td><td>@DateTime.Now.Day</td>

</tr>

<tr>

<td>Hour</td><td>@DateTime.Now.Hour</td>

</tr>

<tr>

<td>Minute</td><td>@DateTime.Now.Minute</td>

</tr>

<tr>

<td>Second</td><td>@DateTime.Now.Second</td>

</tr>

</td>

</table>

If and Else Conditions

An essential component of element site pages is that you can figure out what to do in light of conditions.

@{

var text =” “;

if(DateTime.Now.Hour > 12)

{text = “Good Morning ji”}

else

{text = &quot;Good Noon ji&quot;;}

}

<html>

<body>

<p>Hi My message is @text</p>

</body>

</html>

*****************************************************************************************************

For more details and queries please feel free to email, visit or call us. Wishing you the very best for all your future endeavors.
Helpline: 9814666333, 8699444666
Email: info@technocampus.co.in

Please fill the form and we shall contact you soon.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s