ASP.NET Sample Programs with Source Code

ASP.NET Sample Programs:

ASP.NET is a web development framework that is used to build dynamic web pages, interactive web services, and robust data-driven web applications. It is a part of the Microsoft .NET framework. It stands for Active Server Pages. Integrated Development Environment (IDE) is an application used by coders to ease their software development tasks.

ASP.NET is one of the most famous frameworks for students and developers to develop their development projects. In 2002, Microsoft released the first version of the ASP.NET framework. It is based on the CLR (Common Language Runtime) which enables developers to build ASP.NET applications. Common Language Runtime includes the classes, interfaces and data types supports a wide range of technologies.

ASP.NET Features:

i. Cross-platform & container support

ii. Cross-platform & container support

iii. Asynchronous via async/await

iv. Multiple environments and development mode

v. Unified MVC & Web API frameworks

vi. Cross-Site Request Forgery (CSRF) Protection.

vii. WebSockets & SignalR

ASP.NET Projects with Source Code:

For your first sample ASP.NET projects, As you will see, ASP.NET is very easy. You will be up and running in no time at all.

1. Start a new document in either Visual Studio.NET or the text editor of your choice.
2. Enter the code into the document, and then go to File -> Save As and name it HelloWorld.ASPX in your Web root folder.
3. Launch your Web browser and enter the location of the new file (such as- localhost/helloworld.aspx).

The ASP.NET Sample Programs with Source Code are given below:

<html>
<head>
<title>Example 1: Hello World</title>
</head>
<body bgcolor=white>
<h1>
<% response.write("Hello World") %>
</h1>
</body>
</html>

Sending E-mail Program in ASP.NET:

<%@ Page Language=”C#” AutoEventWireup=”true” CodeBehind=”SendMail.aspx.cs” Inherits=”SendMail.SendMail” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”>
<html xmlns=”https://www.w3.org/1999/xhtml”>
<head runat=”server”>
<title></title>
</head>
<body>
<form id=”form1″ runat=”server”>
<div>
<table style=”width: 56%;” align=”center”>
<tr>
<td align=”center” colspan=”2″ width=”90%”>
 
<strong>How to ASP.NET Sending Email</strong></td>
</tr>
<tr>
<td align=”right”>

 From:</td>

<td align=”left”>

<asp:TextBox ID=”txtFrom” runat=”server”></asp:TextBox>

</td>

</tr>

<tr>

<td align=”right”>

 To:</td>

<td align=”left”>

<asp:TextBox ID=”txtTo” runat=”server”></asp:TextBox>

</td>

</tr>

<tr>

<td align=”right”>

Subject</td>

<td align=”left”>

<asp:TextBox ID=”txtSubject” runat=”server”></asp:TextBox>

</td>

</tr>

<tr>

<td align=”right”>

Message</td>

<td align=”left”>

<asp:TextBox ID=”txtMsg” runat=”server” TextMode=”MultiLine”></asp:TextBox>

</td>

</tr>

<tr>

<td align=”center” colspan=”2″>

<asp:Button ID=”btnSend” runat=”server” onclick=”btnSend_Click” Text=”Send” />

</td>

</tr>

</table>
</div>
</form>
</body>
</html>

File: SendMail.apsx.cs

ASP.NET Sample Programs with Source Code

File: SendMail.apsx.designer.cs

<auto-generated>
</auto-generated>
namespace SendMail {
public partial class SendMail {
<summary>
</summary>
<remarks>
</remarks>

protected global::System.Web.UI.HtmlControls.HtmlForm form1;

<summary>
</summary>
<remarks>
</remarks>

protected global::System.Web.UI.WebControls.TextBox txtFrom;

<summary>
</summary>
<remarks>
</remarks>

protected global::System.Web.UI.WebControls.TextBox txtTo;

<summary>
</summary>
<remarks>
</remarks>

protected global::System.Web.UI.WebControls.TextBox txtSubject;

<summary>
</summary>
<remarks>
</remarks>

protected global::System.Web.UI.WebControls.TextBox txtMsg;

<summary>
</summary>
<remarks>
</remarks>
protected global::System.Web.UI.WebControls.Button btnSend;
}
}

Output:

ASP.NET Sample Programs with Source Code