首 页 | 新 闻 | 技术中心 | 第二书店 | 《程序员》 | 《开发高手》 | 社 区 | 黄 页 | 人 才
移 动专 题SUNIBM微 软微 创精 华Donews人 邮
我的技术中心 
我的分类 我的文档
全部文章 发表文章
专栏管理 使用说明



 RSS 订阅 
最新文档列表
Windows/.NET
.NET  (rss)    
Visual C++  (rss)    
Delphi  (rss)    
Visual Basic  (rss)    
ASP  (rss)    
JavaScript  (rss)    
Java/Linux
Java  (rss)    
Perl  (rss)    
综合
其他开发语言  (rss)    
文件格式  (rss)    
企业开发
游戏开发  (rss)    
网站制作技术  (rss)    
数据库
数据库开发  (rss)    
软件工程
其他  (rss)    

积极原创作者 
tellmenow (22)
cutemouse (22)
softj (78)
iiprogram (69)
qdzx2008 (50)
goodboy1881 (14)
wangchinaking (58)
fancyhf (1)
harrymeng (41)
yjz0065 (113)
CSDN - 文档中心 - .NET 阅读:2751   评论: 2    参与评论
标题   aspx页面中动态创建控件     选择自 ouyang76cn 的 Blog
关键字   动态创建控件,aspx
出处  

<%@page language="C#"%>
<%@import namespace="System.Data"%>
<%@import namespace="System.Data.OleDb"%>
<%@import namespace="System.Text"%>

<style type="text/css">
   TD.ProductDesc
   {
 font-family: Verdana;
        font-size: small;
 color: #FF3333;
 width: 100%;
 vertical-align: top;
   }
</style>
<script language="c#" runat="server">

 Hashtable hashProductName = new Hashtable();
 Hashtable hashProductDesc = new Hashtable();

public void page_load(Object obj,EventArgs e)
{

 hashProductName[0] = "Jalapeno Dip" ;
 hashProductName[1] = "Smoked Sausage" ;
 hashProductName[2] = "Shrimp Fiesta" ;
 hashProductName[3] = "Jerk Chicken" ;
 hashProductName[4] = "Beer-Battered Fish" ;
 hashProductName[5] = "Bacon Burger" ;
 hashProductName[6] = "Sirloin Tip" ;
 hashProductName[7] = "Baked Alaska" ;
 hashProductName[8] = "Fried Chicken" ;
 hashProductName[9] = "Fresh Garden Salad" ;
 hashProductName[10] = "One Pea" ;

 hashProductDesc[0] = "Simmered in mayonaise and wine, this Jalapeno Dip will make your eyes water" ;
 hashProductDesc[1] = "Mouth watering and delicious sausage" ;
 hashProductDesc[2] = "East Coast's finest shrimp" ;
 hashProductDesc[3] = "A real island experience you will not forget" ;
 hashProductDesc[4] = "Pabst Blue Ribbon and Fish. Wow!" ;
 hashProductDesc[5] = "Big, juicy, and bursting with flavor" ;
 hashProductDesc[6] = "Delicate cuts with no fat" ;
 hashProductDesc[7] = "Fine dessert comprised of sponge cake topped with ice cream and covered with meringue. " ;
 hashProductDesc[8] = "Country cookin'" ;
 hashProductDesc[9] = "Crispy iceberg lettuce and a garden of vegtables" ;
 hashProductDesc[10] = "A single green pea that will leave you craving more" ;

 for (int i=0; i<=10; i++)
 {
   LinkButton LB5= new LinkButton();
   LB5.Text = hashProductName[i].ToString();
   LB5.CommandName = "Products";
   LB5.CssClass = "ProductLinks";
   LB5.CommandArgument = i.ToString() ;
   LB5.Command += new System.Web.UI.WebControls.CommandEventHandler(OnLinkClick);
   LinkList.Controls.Add(LB5);
   LinkList.Controls.Add(new LiteralControl("<br>"));
 }
}

private void OnLinkClick(object O, System.Web.UI.WebControls.CommandEventArgs E)
{
 int RecordId = Int32.Parse(E.CommandArgument.ToString());
 tablecellMessage.Text="<b>"+hashProductName[RecordId].ToString()+"</b><br><i>"+hashProductDesc[RecordId].ToString()+"</i>";
}
</script>

<form runat="server">

<asp:Table CellPadding=6 CellSpacing=2 BorderColor="#DDDDDD" BorderStyle=Solid BorderWidth=2 Runat=server>
<asp:TableRow Runat=server>
  <asp:TableCell id=LinkList Wrap=False BackColor="#FFFFFF" Runat=server/>
  <asp:TableCell id="tablecellMessage" CssClass="ProductDesc" Runat=server></asp:TableCell>
</asp:TableRow>
</asp:Table>

</form>
<asp:label id="message" forecolor="red" runat="server"/>


相关文章
对该文的评论
biduan ( 2004-05-14)
没有注释不算好啊
ouyang76cn ( 2003-02-24)
up