posted by 써니루루 2007. 3. 7. 16:24

참조 : 뇌를 자극하는 ASP.NET p 211

HTML의 List를 출력하는 UL, LI 테그등으로 랜더링 되는 테그들입니다.
3번째 불릿티드 리스트에는 클릭이벤트의 처리를 했습니다.

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="p221.aspx.cs" Inherits="p221" %>

<!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>BulletedList</title>
    <script runat="server">
        protected void BulletedList3_Click(object sender, BulletedListEventArgs e)
        {
            Response.Write("선택한 목록 번호 : " + e.Index.ToString()
                + "<br />선택한 목록 Value : "
                + BulletedList3.Items[e.Index].Value
                + "<br />선택한 목록 Text : "
                + BulletedList3.Items[e.Index].Text
            );
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table style="width: 583px">
            <tr>
           
            <td>
            <h3>Disc</h3>
            <asp:BulletedList ID="BulletedList1" runat="server">
                <asp:ListItem>Item #1</asp:ListItem>
                <asp:ListItem>Item #2</asp:ListItem>
                <asp:ListItem>Item #3</asp:ListItem>
                <asp:ListItem>Item #4</asp:ListItem>
            </asp:BulletedList>
            </td>
           
            <td>
            <h3>Circle</h3>
            <asp:BulletedList ID="BulletedList2" BulletStyle="Circle" DisplayMode="HyperLink" runat="server">
                <asp:ListItem Value="http://daum.net">Item #1</asp:ListItem>
                <asp:ListItem Value="http://naver.com">Item #2</asp:ListItem>
                <asp:ListItem Value="http://yahoo.co.kr">Item #3</asp:ListItem>
                <asp:ListItem Value="http://google.co.kr">Item #4</asp:ListItem>
            </asp:BulletedList>
            </td>
           
            <td>
            <h3>Square</h3>
            <asp:BulletedList ID="BulletedList3" BulletStyle="square" DisplayMode="LinkButton" runat="server" OnClick="BulletedList3_Click">
                <asp:ListItem>Item #1</asp:ListItem>
                <asp:ListItem>Item #2</asp:ListItem>
                <asp:ListItem>Item #3</asp:ListItem>
                <asp:ListItem>Item #4</asp:ListItem>
            </asp:BulletedList>
            </td>
           
           
            <td style="width: 90px">
            <h3>Numbered</h3>
            <asp:BulletedList ID="BulletedList4" BulletStyle="Numbered" FirstBulletNumber="3" runat="server">
                <asp:ListItem>Item #1</asp:ListItem>
                <asp:ListItem>Item #2</asp:ListItem>
                <asp:ListItem>Item #3</asp:ListItem>
                <asp:ListItem>Item #4</asp:ListItem>
            </asp:BulletedList>
            </td>
           
            </tr>
           
        </table>
    </div>
    </form>
</body>
</html>

posted by 써니루루 2007. 3. 7. 11:37

출처 : 뇌를 자극하는 ASP.NET p 219


일반적으로 사이트 베너를 표시할때는 자바스크립트나 서버안에서 랜덤처리하는 부분을 구현해서 작업하게 됩니다.
이런 베너출력을 간편하게 처리할 수 있도록 제공되는 컨트롤 입니다.

예제에선 간단한 xml파일을 읽어들이도록 했지만 다른 DataSource를 바인딩할 수 있습니다.


// p219.aspx
<%@ Page Language="C#" %>

<!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>AdRotator</title>
</head>

<body>
    <form id="form1" runat="server">
    <div>
        <asp:AdRotator ID="AdvSection1" runat="server" BorderWidth="1" BorderStyle="Dashed" Height="100px" Width="400px" AdvertisementFile="~/ad.xml" />
    </div>
    </form>
</body>

</html>



// ad.xml 파일
<?xml version="1.0" encoding="utf-8" ?>
<Advertisements>
 <Ad>

  <ImageUrl>~/Images/bannger1.gif</ImageUrl>
  <NavigateUrl>http://www.microsoft.com</NavigateUrl>
  <AlternateText>마소</AlternateText>
  <Keyword>Microsoft</Keyword>
  <Impressions>50</Impressions>

 </Ad>
 <Ad>

  <ImageUrl>~/Images/bannger2.gif</ImageUrl>
  <NavigateUrl>http://www.i-ruru.com</NavigateUrl>
  <AlternateText>루루</AlternateText>
  <Keyword>ruru</Keyword>
  <Impressions>60</Impressions>

 </Ad>
 <Ad>

  <ImageUrl>~/Images/bannger3.gif</ImageUrl>
  <NavigateUrl>http://www.allblog.net</NavigateUrl>
  <AlternateText>올블로그</AlternateText>
  <Keyword>allblog</Keyword>
  <Impressions>50</Impressions>

 </Ad>
</Advertisements>