Demonstrate Dropdown Event Concept
Demonstrate Dropdown Event Concept
NET program to
demonstrate DropDown event concept.
Using System;
Using System.Web.UI;
Using System.Web.UI.WebControls;
If (!IsPostBack)
}
<!DOCTYPE html>
<html xmlns=http://www.w3.org/1999/xhtml>
<head runat=”server”>
</head>
<body>
</asp:DropDownList>
<br />
</form>
</body>
</html>
Using System;
Class Program
{
Static void Main()
{
// String Compare() method
String str1 = “Hello”;
String str2 = “World”;
If (comparisonResult == 0)
{
Console.WriteLine(“str1 and str2 are equal.”);
}
Else if (comparisonResult < 0)
{
Console.WriteLine(“str1 comes before str2 alphabetically.”);
}
Else
{
Console.WriteLine(“str1 comes after str2 alphabetically.”);
}
Using System;
Class Program
{
Static void Main()
{
// Using Copy() method
String originalString = “Hello, World!”;
String copiedString = string.Copy(originalString);
OUTPUT
Original String: Hello, World!
Here’s an ASP.NET Web Forms application that displays the current month’s
calendar using the `Calendar` control:
### Steps:
1. Create a new ASP.NET Web Forms project in Visual Studio.
2. Add a `WebForm` page (e.g., `Default.aspx`).
3. Use the following code for the design (`.aspx`) and the code-behind
(`.aspx.cs`).
```html
<%@ Page Language=”C#” AutoEventWireup=”true” CodeFile=”Default.aspx.cs”
Inherits=”Default” %>
<!DOCTYPE html>
<html xmlns=http://www.w3.org/1999/xhtml>
<head runat=”server”>
<title>Current Month Calendar</title>
</head>
<body>
<form id=”form1” runat=”server”>
<div style=”text-align: center;”>
<h2>Current Month Calendar</h2>
<asp:Calendar ID=”Calendar1” runat=”server”></asp:Calendar>
</div>
</form>
</body>
</html>
```
```csharp
Using System;
### Explanation:
- The **Calendar Control** in ASP.NET is used to display the calendar in a web
form.
- In the `Page_Load` event, the `Calendar1.VisibleDate` property is set to the
current date (`DateTime.Today`) to display the current month.
- `!IsPostBack` ensures that the calendar is set to the current month only on the
initial page load and not on every postback.