AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
ASP.NET CLASIC Tutorial

ASP Introduction


Free Tutorial ASP.NET

ASP.NET is a free web framework for creating great websites and web applications using HTML, CSS, and JavaScript.
You can also create Web APIs and use real-time technologies like Web Sockets.

Microsoft introduced the technology called Active Server Pages in December 1996.
It is part of Internet Information Services (IIS) since version 3.0 and is an active pages technology that allows the use of different scripts and components in conjunction with traditional HTML to display dynamically generated pages.

Microsoft's contextual definition is that "Active Server Pages are a free and open application environment in which HTML code, scripts, and server ActiveX components can be combined to create dynamic and powerful solutions for the web."


ASP Syntax

 

The code can be inserted anywhere within the HTML code. The code blocks are enclosed in @ {...}. Inline variables and functions begin with @. The code inside @ follows normal C # or VB rules.

Single line declaration:
@ {var firstNumber = 1; }

Multi-line code block:
@ {
var secondNumber = 2;
var total = firstNumber + secondNumber;
}

Using an inline variable:

The total count is @total


Using an inline variable explicitly:

Item @ (item.Id)

For this particular example, we won't be able to use the implicit syntax because Item@item.Id looks like an email and Razor will process it as such.


ASP Variables

 

Just like regular C # code, you can define variables in Razor, to save information for later use. If you are already within the scope (Scope) of the code, let's say, within an if statement or another control structure, you can define them directly. If you are within an HTML markup scope, you can use a Razor code block, as we described in a previous article, to define your variable within. Here's an example:<br /><br />

@ {
string helloWorldMsg = "Hello, world!";
}
Of course you can show as output that simple, either directly in the code block or outside of it, referencing the name. Here's an example of this:

@ {
string helloWorldMsg = "Hello, world!";
}

<div>
@helloWorldMsg
</div>
Of course you can work around and manipulate your variables and apply logic on it, just like you would in C #:

@ {
string helloWorldMsg = "Good day";
if (DateTime.Now.Hour> 17)
{
helloWorldMsg = "Good evening";
}
helloWorldMsg + = ", world!";
helloWorldMsg = helloWorldMsg.ToUpper ();
}

<div>
@helloWorldMsg
</div>


ASP Procedures

Implementing Stored Procedures in ASP.NET

In order to implement sp in asp.net project first we need to create a sp in database server or sql server. So let's open up Microsoft SQL Server 2008 and select a database (if you have not created a database then create a new one). Now maximize the database folder and also maximize the "programmability" folder inside the "programmability" you will find stored procedure folder.

Sample Code SP

   CREATE PROCEDURE usp_sample

@var1 varchar(100),
@var2 int

AS
BEGIN
Select * From Employee Where Employee_ID=@var1
END
GO


ASP Conditionals

Conditional Statements

Conditional statements are used to perform different actions for different decisions.

In VBScript we have four conditional statements:

if condition then 
   statements_1
else 
   statements_2
end if

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

if condition_1 then
   statement_1
[elseif condition_2 then
   statement_2]
...
[elseif condition_n_1 then
   statement_n_1]
[else
   statement_n]
end if

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

<%@ language="vbscript"%>
<%
Dim Result
Result = 70

if Result >= 57 then
    response.write("Pass <br />")
else
    response.write("Fail <br />")
end if
%>


ASP Looping

ASP Looping

The two major groups of loops are For..Next and Do..Loop. The For...Next statements are best used when you want to perform a loop a specific number of times. The Do...Loop statements are best used to perform a loop an undetermined number of times. In addition, you can use the Exit keyword within loop statements.

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

<%@ language="vbscript" %>
<%
For i = 0 to 10 Step 2 'use i as a counter
 response.write("The number is " & i & "<br />")
Next
%>

**********

<%@ language="vbscript" %>
<%
response.write("<h1>Multiplication table</h1>")
response.write("<table border=2 width=50%")

For i = 1 to 9             'this is the outer loop
   response.write("<tr>")
   response.write("<td>" & i & "</td>")
 
   For j = 2 to 9          'inner loop
        response.write("<td>" & i * j & "</td>")
   Next 'repeat the code and move on to the next value of j   

   response.write("</tr>")
Next 'repeat the code and move on to the next value of i

response.write("</table>")
%>


ASP Forms

ASP.NET Web Pages - HTML Forms

A form is a section of an HTML document where you put input controls (text boxes, check boxes, radio buttons, and pull-down lists).

Creating an HTML Input Page

<!DOCTYPE html>
<html> 
<body> 
@{
if (IsPost)

string companyname = Request["CompanyName"]; 
string contactname = Request["ContactName"]; 
<p>You entered: <br> 
Company Name: @companyname <br> 
Contact Name: @contactname </p> 
}
else
{
<form method="post" action="">
Company Name:<br> 
<input type="text" name="CompanyName" value=""><br>
Contact Name:<br><br>
<input type="text" name="ContactName" value=""><br><br>
<input type="submit" value="Submit" class="submit">
</form> 
}
}
</body> 
</html>


    HTML Image tag, code...
    How to code in HTML...
    HTML text tag...
    HTML text, how to display...
    Container responsive styles...
    HTML container tag...
    HTML container...
    Send forgot password by mail or message ...
    PHP MySQL simple login system...
    Check for duplicate username live or ema...
    How to create simple search engine using...
    Diseño de sitio web CSS Layout...
    Diseño de caja flexible CSS3...
    Botones en CSS...
    ID y Clase, Diferencias entre Class e Id...
    Esquina redondeada CSS...
    Tamaño de caja css box-sizing: border-b...
    Alineación CSS...
    Altura y Anchura CSS...
    Bordes CSS...
    Margen CSS...
    Relleno CSS...
    Modelo de caja CSS...
    Tablas CSS...




Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


right-foot