Bind a ListBox with an array of colors and change background color of the page
accordingly in [Link]
[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="Color" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Color ListBox</title>
</head>
<body id="bodyTag" runat="server">
<form id="form1" runat="server">
<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true"
OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
</asp:ListBox>
</form>
</body>
</html>
[Link]
using System;
public partial class Color : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
string[] colors = { "Red", "Green", "Blue", "Yellow", "Pink", "Orange" };
[Link] = colors;
[Link]();
}
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{
[Link]["background-color"] = [Link];
}
}
Create an [Link] page and use the Page Load method to display the current
date and time. in [Link]
[Link]
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="[Link]"
Inherits="DateTimePage" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Date and Time</title>
</head>
<body>
<form id="form1" runat="server">
<h2>Current Date and Time:</h2>
<asp:Label ID="Label1" runat="server" Font-Size="Large"></asp:Label>
</form>
</body>
</html>
[Link]
using System;
public partial class DateTimePage : [Link]
{
protected void Page_Load(object sender, EventArgs e)
{
// Display current date and time
[Link] = [Link]();
}
}