3a. Create a simple web page with various sever controls to demonstrate setting and use of their properties. (Example : AutoPostBack)

Program:



Default.aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Practical_3a._Default" %>
  
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server">

<title>Untitled Page</title>
</head>
<body>


<form id="form1" runat="server">
<div>

<asp:ListBox ID="ListBox1" runat="server" AutoPostBack="True" Height="77px">
<asp:ListItem>FYIT</asp:ListItem>
<asp:ListItem>SYIT</asp:ListItem>
<asp:ListItem>TYIT</asp:ListItem>
</asp:ListBox>

</div>

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <p>

<img alt="" src="it.png" style="width: 137px; height: 139px; margin-right: 0px" title="IT" /></p>

<p>
<asp:HyperLink ID="HyperLink1" runat="server" BackColor="#FFFF99"
BorderColor="Red" ForeColor="#003300"

NavigateUrl="https://www.google.com/">HyperLink</asp:HyperLink> </p>
</form>
</body>
</html>



Default.aspx.cs

using System;
using System.Collections;
using System.Configuration;

using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;

using System.Xml.Linq;

namespace Practical_3a
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (ListBox1.SelectedItem != null)
{


Label1.Text = "You Selected: " + ListBox1.SelectedItem.ToString();

}
else
{
Label1.Text = "Select Any Item";

}
}
protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

}
}

Comments