asp.net 动态添加多个用户控件
动态添加多个相同用户控件,并使每个用户控件获取不同的内容。
用户控件代码:
代码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;
}
asp.net 动态添加多个用户控件的更多相关文章
- asp.net动态加载ascx用户控件
原文:asp.net动态加载ascx用户控件 在主aspx/ascx文件中,将目标ascx1,ascx2控件拖拉到其页面中,然后删除,目的是要生成:Register 代码,然后在主文件中定义DIV或T ...
- ASP.NET同页面内【用户控件与父页面】以及【用户控件与用户控件】之间方法调用
在用户控件中,获取父页面的方法 1:方法没有参数(userInfor()) string userInfor = Convert.ToString(this.Page.GetType().GetMet ...
- (转载)VC/MFC 工具栏上动态添加组合框等控件的方法
引言 工具条作为大多数标准的Windows应用程序的 一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开 ...
- VC/MFC 工具栏上动态添加组合框等控件的方法
引言 工具条作为大多数标准的Windows应用程序的一个重要组成部分,使其成为促进人机界面友好的一个重要工具.通过工具条极大方便了用户对程序的操作,但是在由Microsoft Visual C++开发 ...
- Android 在程序中动态添加 View 布局或控件
有时我们需要在程序中动态添加布局或控件等,下面用程序来展示一下相应的方法: 1.addView 添加View到布局容器 2.removeView 在布局容器中删掉已有的View 3.LayoutPar ...
- winform PictureBox图片上动态添加Label或其他控件
效果图: 代码: //分页或者多次加载时,需要删除之前产生的lable等控件 ; tabID < ; tabID++) { foreach (Control control in this.ta ...
- 在ASP.NET中动态加载内容(用户控件和模板)
在ASP.NET中动态加载内容(用户控件和模板) 要点: 1. 使用Page.ParseControl 2. 使用base.LoadControl 第一部分:加载模板 下 面是一个模板“<tab ...
- (九)ASP.NET自定义用户控件(2)
http://www.cnblogs.com/SkySoot/archive/2012/09/04/2670678.html 用户控件 在 .NET 里,可以通过两种方式把自己的控件插入到 Web 窗 ...
- ASP.NET MVC中加载WebForms用户控件(.ascx)
原文:ASP.NET MVC中加载WebForms用户控件(.ascx) 问题背景 博客园博客中的日历用的是ASP.NET WebForms的日历控件(System.Web.UI.WebControl ...
随机推荐
- JavaWeb response对象常用操作
JavaWeb response对象常用操作 CreationTime--2018年7月18日10点42分 Author:Marydon 1.设置响应内容类型 方式一 response.setCo ...
- 执行pig出错Unhandled internal error. Found interface jline.Terminal, but class was expected
执行pig时报例如以下错误 2015-07-14 10:41:12,869 [main] ERROR org.apache.pig.Main - ERROR 2998: Unhandled inter ...
- 视频中的DTS与PTS的理解
原文地址:http://blog.itpub.net/30004768/viewspace-1338882/ DTS(解码时间戳)和PTS(显示时间戳)分别是解码器进行解码和显示帧时相对于SCR(系 ...
- C#指南,重温基础,展望远方!(9)C#接口
接口定义了可由类和结构实现的协定. 接口可以包含方法.属性.事件和索引器. 接口不提供所定义的成员的实现代码,仅指定必须由实现接口的类或结构提供的成员. 接口可以采用多重继承. 在以下示例中,接口 I ...
- ocr 识别 github 源码
参考 [1] https://github.com/eragonruan/text-detection-ctpn [2] https://github.com/senlinuc/caffe_ocr [ ...
- Struts2初学 Struts.xml详解二
A.使用继承实现设置全局视图 package节点中还可以设置全局的视图,如: <global-results> <result name="e ...
- Linux strace命令使用详解
strace是Linux环境下的一款程序调试工具,用来监察一个应用程序所使用的系统调用及它所接收的系统信息. 可谓是 linux 下的调试利器,不仅可以用来找程序错误,系统为什么挂死了,命令为什么报错 ...
- hdu1331(记忆化搜索)
#include<iostream> #include<stdio.h> #include<string.h> using namespace std; typed ...
- sqlservler 分页的实现
转载自:http://www.cnblogs.com/FreeDong/archive/2011/09/27/2193240.html 当我们显示列表信息的时候,我们常常以分页形式显示,当然在ASP. ...
- love2d杂记9--光照效果
光照效果需要用shader,这个我一直没学,现在时间较少,先放到这里,有时间我再补,如果大家 发现好的opengl shader教程(如果没记错的love2d用的是glsl 1.1),推荐一下. 这里 ...