Showing posts with label Using Server Control. Show all posts
Showing posts with label Using Server Control. Show all posts

Saturday, 10 December 2011

Simple Page of aspx using server controls of List


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="SimpleWebSite._Default" %>

<script runat="server">
const int ItemCount=10;

    String GetDisplayItem(int n){
    return "TahirListItem#"+n.ToString();
     }

    protected override void OnLoad(EventArgs e)
    {
        //Clear out Items populated by static declaration

        DisplayList.Items.Clear();

        for (int i = 0; i < ItemCount; i++)
            DisplayList.Items.Add(new ListItem(GetDisplayItem(i)));

        tahirHeading.InnerHtml = "Total number of Item=" + ItemCount.ToString();
           
        base.OnLoad(e);
    }
   
   
   
   
       
</script>

<!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>Tahir Khalid Simple Asp.net in C# Page with Simple.Aspx using server-side Controls</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
   
    </div>
    <asp:BulletedList ID="DisplayList" runat="server">
    <asp:ListItem>Tahir's List with Server control  Item1</asp:ListItem>
    <asp:ListItem>Tahir's List with Server control  Item2</asp:ListItem>
    <asp:ListItem>Tahir's List with Server control  Item3</asp:ListItem>
    <asp:ListItem>Tahir's List with Server control  Item4</asp:ListItem>
    <asp:ListItem>Tahir's List  with Server control Item5</asp:ListItem>
    </asp:BulletedList>
    <h2 runat="server" id="tahirHeading">Total Number of Item=xx</h2>
    </form>
</body>
</html>