发布于 2016-05-31 02:57:10 | 144 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的精品教程,程序狗速度看过来!

ASP.NET

ASP.NET 是.NET FrameWork的一部分,是一项微软公司的技术,是一种使嵌入网页中的脚本可由因特网服务器执行的服务器端脚本技术,它可以在通过HTTP请求文档时再在Web服务器上动态创建它们。 指 Active Server Pages(动态服务器页面) ,运行于 IIS(Internet Information Server 服务,是Windows开发的Web服务器)之中的程序 。


动态添加多个相同用户控件,并使每个用户控件获取不同的内容。
用户控件代码:
代码WebControls
 
using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 
using System.Web.UI; 
using System.Web.UI.WebControls; 
namespace xuyuanwang.myControl 
{ 
public partial class Lablexuyuan : System.Web.UI.UserControl 
{ 
string a = "ok"; 
public string A 
{ 
set 
{ 
a = value; 
} 
get 
{ 
return a; 
} 
} 
protected void Page_Load(object sender, EventArgs e) 
{ 
Label1.Text = A; 
} 
} 
} 

aspx页面代码:
代码
 
public partial class WebForm1 : System.Web.UI.Page 
{ 
protected void Page_Load(object sender, EventArgs e) 
{ 
} 
protected void Button1_Click(object sender, EventArgs e) 
{ 
myControl.Lablexuyuan ctl = (myControl.Lablexuyuan)Page.LoadControl("myControl/Lablexuyuan.ascx"); 
ctl.A = this.TextBox1.Text; 
ArrayList list = addl(ctl); 
for (int i = 0; i < list.Count; i++) 
{ 
myControl.Lablexuyuan ctl2 = (myControl.Lablexuyuan)list[i]; 
this.UpdatePanel1.ContentTemplateContainer.Controls.Add(ctl2); 
} 
} 
private System.Collections.ArrayList addl(myControl.Lablexuyuan l) 
{ 
System.Collections.ArrayList list = null; 
if (Session["a"] != null) 
{ 
list = (ArrayList)Session["a"]; 
} 
else 
{ 
list = new ArrayList(); 
} 
list.Add(l); 
Session["a"] = list; 
return list; 
} 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务