⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cruiseselector.ascx

📁 Developing Microsoft ASP.NET Server Controls and Components
💻 ASCX
字号:
<%@ Control Language="c#" ClassName="CruiseSelector" %>
<script runat="server">
  private void LoadDataSource() {
      ArrayList list = new ArrayList();
      list.Add("Programming ASP.NET Pages");  
      list.Add("ASP.NET Tips and Tricks");
      list.Add("XML Web Services");
      list.Add("Authoring Server Controls 101");
      list.Add("Professional Server Controls"); 
      myList.DataSource = list;
  }

  void Page_Load(object sender, EventArgs e) {
      if (!IsPostBack) {
          label1.Text = "Last chance to sign up for an ASP.NET dinner cruise!!";
          LoadDataSource();
          myList.DataBind();
      }
  }

  // The handler for the ItemCommand event of the DataList.
  private void MyList_ItemCommand(object source, DataListCommandEventArgs e)
  {
      Label l = (Label)e.Item.FindControl("label");
      string s = "You are registered for the "
                + "<b>" + l.Text
                + "</b> dinner cruise.";
      label1.Text = s;
      myList.Enabled = false;
  }
</script>
<p />
<asp:Label id="label1" Font-Name="Verdana" Font-Size="12pt" runat="server" />
<p />
<asp:DataList runat="server" id="myList" Font-Name="Verdana" Font-Size="16pt" BorderColor="Gray" BorderWidth="1px" CellSpacing="0" CellPadding="2" GridLines="Both" onItemCommand="MyList_ItemCommand">
  <HeaderStyle ForeColor="Black" BackColor="LightBlue" HorizontalAlign="Center" />
  <ItemStyle ForeColor="Black" BackColor="#EEEEEE" HorizontalAlign="Right" />
  <AlternatingItemStyle BackColor="#DCDCDC" />
  <SelectedItemStyle ForeColor="White" BackColor="#000084" />
  <HeaderTemplate>
    <asp:Label id="headerLabel" runat="server" Text="ASP.NET Dinner Cruises" />
  </HeaderTemplate>
  <ItemTemplate>
    <asp:Label id="label" runat="server" 
      Text='<%# Container.DataItem %>'/>
    &nbsp;&nbsp;
    <asp:Button button="button" runat="server" id="selectButton" CommandName="Select" Text="Select" ForeColor="Blue" />
  </ItemTemplate>
</asp:DataList>
</p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -