Eclipse开发平台 Eclipse集成开发环境 Java技术参考 J2EE企业应用项目 J2EE开发框架整合应用
Visual Studio 2008 技术 Visual Studio 2008集成环境 LINQ SQL Server 2008数据库 Silverlight WCF WPF WWF
平台综合 开发平台技术动态 跨平台开发 软件信息技术与商业 国外媒体技术资讯
程讯网下载 精品代码 — J2EE应用下载 精品代码 — ASP.NET应用 常用J2EE开发框架 流行ASP.NET开发框架

搜索
Google
 
最新文章
对“职业生涯及规划”的一些想法与建议
 
Visual Studio 10将会怎样?
 
三十怎么了? 心态最重要!
 
访问Microsoft格式文件的Jakarta-POI API库的.NET版本
 
dashCommerce 3.X如何安装Microsoft SQL Server 2005 Express Edition的高级服务功能
 
.net 2.0运行时提示以下错误:authentication mode=Windows 解决方法如下
 
在浏览器中发贴子时实现自动添加贴子签名档的BHO对象设计
 
C#下用Browser Helper Object对象实现拦截IE浏览器的各项消息的IE插件
 
Build a Managed BHO and Plug into the Browser
 
在C#中用WM_COPYDATA消息来实现进程间通信的详细编码
 
BHO 浏览器辅助对象关联原理、编写流程
 
Oracle8i的卸载
 
Oracle9i图形工具OEM的简介
 
详细介绍整个Oracle9i软件的安装过程
 
C# 面向对象设计模式纵横谈 - 18、Iterator迭代器(行为型模式)
 
 
asp.net(c#)中动态创建添加控件的一个例子 - .NET技术博客圈、俱乐部群观点精华
 
内容摘要 -


全文 -

asp.net(c#)中动态创建添加控件的一个例子


一个例子,动态添加控件的


<%@ Page Language="C#" %>
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
 if(!IsPostBack)
    ViewState["Count"]=0;
 else
    for(int i=1;i<=(int)ViewState["Count"];i++)
     {
     addproduct(i.ToString());
     }
}
 void addproduct(string num)
 {
     LiteralControl mylabel;
     TextBox mybox = new TextBox();
     mylabel = new LiteralControl();
     mylabel.Text = "<p>" + "产品:" + num;
     PlaceHolder1.Controls.Add(mylabel);
     mybox = new TextBox();
     mybox.ID = "txtProduct" + num;
     PlaceHolder1.Controls.Add(mybox);
 }
protected void add_btn(object sender, EventArgs e)
{
     int count =(int)ViewState["Count"];
     count++;
     ViewState["Count"] = count;
     addproduct(ViewState["Count"].ToString());
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
 <title>动态添加控件</title>
</head>
<body style="font-size: 12px;">
 <form id="form1" runat="server">
 <div>
 <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder>
 <br />
 <asp:Button ID="Button1" runat="server" Text="增加" OnClick="add_btn" />
 </form>
</body>
</html>


 
相关内容
查找更多 ◇ .NET技术博客圈、俱乐部群观点精华