Unit 5 Web Technology and Development
Unit 5 Web Technology and Development
Navigation control in ASP.NET manages the data passing between ASPX pages.
Web applications are having multiple pages interconnected with each other. So
proper navigation system must be there which can help the end user to successfully
ASP.NET 1.x that offers well defined navigation system for the web application.
Only the method which is present for building navigation within web application is
to fill the pages with hyperlinks. The drawbacks of hyperlink are when you move
When the site grows and new pages are added and at that time it is very difficult
for the developer to manage all links in the application. ASP.NET 2.0 and above
consistent way for the user to navigate the website. It enables defining all the links
at central location file as xml file and display those links in list or navigation
SiteMapPath
Menu Control
TreeView
1. SiteMapPath Control
Site maps are XML files which are mainly used to describe the logical structure of
the web application. It defines the layout of all pages in web application and how
they relate to each other. Whenever you want you can add or remove pages to your
site map there by managing navigation of website efficiently. Site map files are
defined with .sitemap extension. <sitemap> element is the root node of the sitemap
file.
SiteMapPath control displays the navigation path of the current page. The path acts
as click able links to previous page. The sitemap path control uses the web. This
control creates the navigation mechanism which is linear path defining where the
user is currently located in navigation arrangement. It helps end user to know his
NodeStyle: This property is used to set the style of all nodes that will be
displayed.
RootNodeStyle: This property is used to set the style on the absolute root
node.
ShowToolTips: This property is used to set the tooltip for the control.
2. Menu Control
Menu is an another navigation control in ASP.NET which is used to display menu
for navigating the web Site. It displays two types of menu static menu and dynamic
menu. Static menu is always displayed in menu Control, by default only menu
items at the root levels are displayed. Dynamic menu is displayed only when the
use moves the mouse pointer over the parent menu that contains a dynamic sub
menu.
CssClass: This property is used to specify the CSS class attribute for the
control.
ImgeUrl: This property is used to specify the image that appear next to the
menu item.
Tooltip: This property is used to specify the tooltip of the menu item when
Text: This property is used to specify the text to display in the menu.
NavigateUrl: This property is used to specify the target location to send the
Target: This property is used to specify the target page location. It can be in
events.
3. TreeView Control
TreeView is an another navigation control used in ASP.NET to display the data in
hierarchical list manner. When TreeView is displayed for the first time, it displays
all of its nodes. User can control it by setting the property called ExpandDepth.
CssClass: This property is used to specify the CSS class attribute for the
control.
The Login control has properties for customized display, for customized messages,
and for links to other pages where users can change their password or recover a
forgotten password. The Login control can be used as a standalone control on a
main or home page, or you can use it on a dedicated login page.
If you use the Login control with ASP.NET membership, you do not need to write
code to perform authentication. However, if you want to create your own
authentication logic, you can handle the Login control's Authenticate event and add
custom authentication code.
What is Globalization?
What is Localization?
Terms
Neutral culture: A culture that has a specified language, but not a region (for
example "en", "es").
Specific culture: A culture that has a specified language and region (for example,
"en-US", "en-GB", "es-CL").
Parent culture: The neutral culture that contains a specific culture (for example,
"en" is the parent culture of "en-US" and "en-GB").
1. Master Page
A Master Page provides a consistent layout for the web application. It contains the
common elements like header, footer, and navigation menu.
Steps:
Create a new Master Page (Site.master).
Define the layout with placeholders for content.
Link content pages to the Master Page.
html
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="Site" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</form>
</body>
</html>
2. Standard Controls
Example:
html
<asp:TextBox ID="txtEmail" runat="server" />
<asp:Button ID="btnSend" runat="server" Text="Send Email"
OnClick="btnSend_Click" />
Enhance the user experience with JavaScript and AJAX for asynchronous
operations.
Example:
Use UpdatePanel for partial page updates.
html
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="txtEmail" runat="server" />
<asp:Button ID="btnSend" runat="server" Text="Send Email"
OnClick="btnSend_Click" />
</ContentTemplate>
</asp:UpdatePanel>
Example:
csharp
Session["UserEmail"] = txtEmail.Text;
5. Uploading Files
Example:
html
<asp:FileUpload ID="fileUpload" runat="server" />
<asp:Button ID="btnUpload" runat="server" Text="Upload"
OnClick="btnUpload_Click" />
Example:
Use GridView to display sent emails.
html
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="True" />
csharp
protected void btnSend_Click(object sender, EventArgs e)
{
string to = txtEmail.Text;
string from = "[email protected]";
string subject = "Test Email";
string body = "This is a test email.";
try
{
client.Send(mail);
lblStatus.Text = "Email sent successfully!";
}
catch (Exception ex)
{
lblStatus.Text = "Error sending email: " + ex.Message;
}
}
Method 2 for Designing a sample email web application in ASP.NET using the
features you mentioned—such as Master Page, Standard Controls, JavaScript,
AJAX, Cookies, Sessions, file uploading, and Data-Bound Controls like GridView
and Repeater—requires building a well-structured project. Below is an outline to
guide you through the key components and code snippets for building such an
application.
The Master Page is used to create a consistent layout for the application. You can
create a master page that contains the header, footer, and navigation that will be
reused across multiple pages.
asp
Copy code
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="Site.master.cs" Inherits="SiteMaster" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Email Web Application</title>
<script src="Scripts/jquery-3.6.0.min.js"></script> <!-- jQuery for AJAX -->
<link href="Styles/Site.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form id="form1" runat="server">
<div>
<header>
<h1>Email Web Application</h1>
<nav>
<ul>
<li><a href="Inbox.aspx">Inbox</a></li>
<li><a href="Compose.aspx">Compose</a></li>
<li><a href="Logout.aspx">Logout</a></li>
</ul>
</nav>
</header>
<div id="content">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</div>
</div>
</form>
</body>
</html>
In the Inbox page, you can use the GridView control to display emails. You can
also use AJAX for partial page updates and JavaScript for enhancing user
interactions.
asp
Copy code
<%@ Page Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Inbox.aspx.cs"
Inherits="EmailApp.Inbox" %>
csharp
Copy code
public partial class Inbox : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
// Simulate email data (you can replace it with a real database)
List<Email> emails = new List<Email>
{
new Email { EmailID = 1, Sender = "[email protected]", Subject =
"Meeting Update", DateReceived = DateTime.Now },
new Email { EmailID = 2, Sender = "[email protected]", Subject =
"Project Proposal", DateReceived = DateTime.Now.AddMinutes(-10) },
// More emails...
};
GridViewInbox.DataSource = emails;
GridViewInbox.DataBind();
}
}
csharp
Copy code
public class Email
{
public int EmailID { get; set; }
public string Sender { get; set; }
public string Subject { get; set; }
public DateTime DateReceived { get; set; }
}
You can use the FileUpload control to allow users to attach files to their emails.
asp
Copy code
<%@ Page Language="C#" MasterPageFile="~/Site.master"
AutoEventWireup="true" CodeBehind="Compose.aspx.cs"
Inherits="EmailApp.Compose" %>
csharp
Copy code
protected void btnSend_Click(object sender, EventArgs e)
{
string recipient = txtRecipient.Text;
string subject = txtSubject.Text;
string body = txtBody.Text;
HttpPostedFile file = FileUpload1.PostedFile;
// Simulate sending email (you can integrate with a real email API like SMTP)
Response.Redirect("Inbox.aspx");
}
AJAX can be used to perform asynchronous operations without reloading the page.
For example, use AJAX to send a request for retrieving emails or updating the
status of an email without reloading the whole page.
javascript
Copy code
$(document).ready(function() {
$("#btnRefresh").click(function() {
$.ajax({
url: "GetEmails.aspx",
method: "GET",
success: function(response) {
$("#GridViewInbox").html(response);
}
});
});
});
For session management, you can use cookies and sessions to store user
information.
asp
Copy code
<%@ Page Language="C#" AutoEventWireup="true"
CodeBehind="Login.aspx.cs" Inherits="EmailApp.Login" %>
csharp
Copy code
protected void btnLogin_Click(object sender, EventArgs e)
{
string username = txtUsername.Text;
string password = txtPassword.Text;