InnerHtml : Table « HTML Controls « ASP.NET Tutorial

Home
ASP.NET Tutorial
1.ASP.Net Instroduction
2.Language Basics
3.ASP.net Controls
4.HTML Controls
5.Page Lifecycle
6.Response
7.Collections
8.Validation
9.Development
10.File Directory
11.Sessions
12.Cookie
13.Cache
14.Custom Controls
15.Profile
16.Configuration
17.LINQ
18.ADO.net Database
19.Data Binding
20.Ajax
21.Authentication Authorization
22.I18N
23.Mobile
24.WebPart
25.XML
ASP.NET Tutorial » HTML Controls » Table 
4.14.3.InnerHtml
<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>BulletedList Control</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <h1>BulletedList Control</h1>
    
     <asp:BulletedList ID="bltList" runat="server" 
          OnClick="bltList_Click" 
          Target="_blank">
      <asp:ListItem Value="http://www.java2s.com/">java2s.com</asp:ListItem>
      <asp:ListItem Value="http://www.java2s.com">java2s.com</asp:ListItem>
      <asp:ListItem Value="http://www.java2s.com" Text="java2s"></asp:ListItem>
     </asp:BulletedList>
    
     <table>
      <tr>
        <td colspan=id="tdMessage" runat="server">
        </td>
      </tr>
       <tr>
         <td>
          <u>BulletStyle</u>
         </td>
         <td>
          <u>FirstBulletNumber</u>
         </td>
         <td>
          <u>DisplayMode</u>
         </td>
       </tr>
       <tr>
         <td>
          <asp:ListBox ID="lbBulletStyle" runat="server" AutoPostBack=true OnSelectedIndexChanged="lb_SelectedIndexChanged">
            <asp:ListItem>NotSet</asp:ListItem>
            <asp:ListItem>Numbered</asp:ListItem>
            <asp:ListItem>LowerAlpha</asp:ListItem>
            <asp:ListItem>UpperAlpha</asp:ListItem>
            <asp:ListItem>LowerRoman</asp:ListItem>
            <asp:ListItem>UpperRoman</asp:ListItem>
            <asp:ListItem>Disc</asp:ListItem>
            <asp:ListItem>Circle</asp:ListItem>
            <asp:ListItem>Square</asp:ListItem>
            <asp:ListItem>CustomImage</asp:ListItem>
          </asp:ListBox>


         </td>
         <td>
          <asp:ListBox ID="lbFirstBulletNumber" runat="server" 
                AutoPostBack=true 
                Width=50
                OnSelectedIndexChanged="lb_SelectedIndexChanged">
            <asp:ListItem Selected="True">1</asp:ListItem>
            <asp:ListItem>2</asp:ListItem>
            <asp:ListItem>3</asp:ListItem>
            <asp:ListItem>4</asp:ListItem>
            <asp:ListItem>5</asp:ListItem>
            <asp:ListItem>6</asp:ListItem>
          </asp:ListBox>
         </td>
         <td>
            <asp:ListBox ID="lbDisplayMode" runat="server" AutoPostBack=true OnSelectedIndexChanged="lb_SelectedIndexChanged">
              <asp:ListItem>NotSet</asp:ListItem>
              <asp:ListItem>Text</asp:ListItem>
              <asp:ListItem>HyperLink</asp:ListItem>
              <asp:ListItem>LinkButton</asp:ListItem>
            </asp:ListBox>
         </td>
       </tr>
     </table>
    </div>
    </form>
</body>
</html>

File: Default.aspx.cs

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

public partial class _Default : System.Web.UI.Page 
{
    protected void lb_SelectedIndexChanged(object sender, EventArgs e){
     ListBox lb = (ListBox)sender;
     string strID = lb.ID;
     string strValue = lb.SelectedValue;

     switch (strID){
       case "lbBulletStyle": BulletStyle style = (BulletStyle)Enum.Parse(typeof(BulletStyle), strValue);
             bltList.BulletStyle = style;

             if (style == BulletStyle.CustomImage)
             {
                bltList.BulletImageUrl = "A.bmp";
             }
             break;

       case "lbFirstBulletNumber":
         bltList.FirstBulletNumber = Convert.ToInt32(strValue);
         break;

       case "lbDisplayMode":
             BulletedListDisplayMode displayMode = (BulletedListDisplayMode)Enum.Parse(typeof(BulletedListDisplayMode), strValue);
             bltList.DisplayMode = displayMode;
             break;

          default:
             break;
     }
   }

  protected void bltList_Click(object sender, BulletedListEventArgs e){
     BulletedList b = (BulletedList)sender;

     tdMessage.InnerHtml = "Selected index: " + e.Index.ToString() +
        "<br>" +
        "Selected value: " + b.Items[e.Index].Value +
        "<br>";
  }
 }
4.14.Table
4.14.1.Dynamically create a HTML table (C#)
4.14.2.Dynamic html table
4.14.3.InnerHtml
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.