Author: admin
-
ASP.NET Razor – C# Logic Conditions
The If Condition C# lets you execute code based on conditions. To test a condition you use an if statement. The if statement returns true or false, based on your test: Example The Else Condition An if statement can include an else condition. The else condition defines the code to be executed if the condition is false.…
-
ASP.NET Razor – C# Loops and Arrays
For Loops If you need to run the same statements repeatedly, you can program a loop. If you know how many times you want to loop, you can use a for loop. This kind of loop is especially useful for counting up or counting down: Example For Each Loops If you work with a collection or…
-
ASP.NET Razor – C# Variables
Variables Variables are used to store data. The name of a variable must begin with an alphabetic character and cannot contain whitespace or reserved characters. A variable can be of a specific type, indicating the kind of data it stores. String variables store string values (“Welcome to W3Schools”), integer variables store number values (103), date…
-
ASP.NET Razor – C# and VB Code Syntax
Main Razor Syntax Rules for C# C# Example Main Razor Syntax Rules for VB Example How Does it Work? Razor is a simple programming syntax for embedding server code in web pages. Razor syntax is based on the ASP.NET framework, the part of the Microsoft.NET Framework that’s specifically designed for creating web applications. The…
-
ASP.NET Razor – Markup
What is Razor? Razor is a markup syntax that lets you embed server-based code (Visual Basic and C#) into web pages. Server-based code can create dynamic web content on the fly, while a web page is written to the browser. When a web page is called, the server executes the server-based code inside the page…
-
ASP.NET Web Pages – Classes
ASP.NET Classes Reference Method Description AsBool(), AsBool(true|false) Converts a string value to a Boolean value (true/false). Returns false or the specified value if the string does not represent true/false. AsDateTime(), AsDateTime(value) Converts a string value to date/time. Returns DateTime. MinValue or the specified value if the string does not represent a date/time. AsDecimal(), AsDecimal(value) Converts…
-
ASP.NET Web Pages – WebSecurity Object
Description The WebSecurity Object provides security and authentication for ASP.NET Web Pages applications. With the WebSecurity object you can create user accounts, login and logout users, reset or change passwords, and more. WebSecurity Object Reference – Properties Properties Description CurrentUserId Gets the ID for the current user CurrentUserName Gets the name of the current user HasUserId Returns…
-
ASP.NET Web Pages – The WebMail Helper
The WebMail Helper The WebMail Helper makes it easy to send an email from a web application using SMTP (Simple Mail transfer Protocol). Scenario: Email Support To demonstrate the use of email, we will create an input page for support, let the user submit the page to another page, and send an email about the…
-
ASP.NET Web Pages – The WebGrid Helper
Doing the HTML Yourself In a previous chapter, you displayed database data by using razor code, and doing the HTML markup yourself: Database Example Using The WebGrid Helper Using the WebGrid helper is an easier way to display data. The WebGrid helper: WebGrid Example WebGrid Object Reference Helper Description WebGrid(data) Creates a new WebGrid object…
-
ASP.NET Web Pages – Helpers
ASP.NET Helpers ASP.NET helpers are components that can be accessed by single lines of Razor code. You can build your own helpers using Razor syntax stored as .cshtml files, or use built-in ASP.NET helpers. You will learn how to use Razor helpers in the next chapters of this tutorial. Below is a short description of…