asp.net 由基类动态向继承的页面添加“button”按钮
解决方案 »
- 怎么用一个对象封装下
- js 判断滚动条的高度位置
- 求救(急):TableAdapter(Optimistic Concurrency Enable)和ObjectDataSource更新数据的空值问题
- 请大家推荐一个好的ASP.net 数据访问组件!
- 100分求助程序创建目录的权限问题...服务器提供商说不给加权限.7456....请各位进来帮我顶一顶.....等待思归,孟子,webdiyer等高手解答!!!!
- 动态生成多个button按钮 如何判断按钮是否可点击
- 实体类参数化查询多个栏目的记录,SQL语句怎么写?
- 关于form验证的问题
- 关于MY97日历控件的使用
- iis中 windows身份验证问题
- GridView疑问
- 怎样将datatable追加到sql数据库中
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;public partial class BasePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
} private void AddControl()
{
var label = new Label {ID = "myLabel", Text = "test"};
label.EnableViewState = true;
var button = new LinkButton {ID = "myButton", Text = "test"};
button.EnableViewState = true;
button.Click += button_Click; this.Form.Controls.Add(label);
this.Form.Controls.Add(button);
} protected override void OnInit(EventArgs e)
{
AddControl();
} protected void button_Click(object sender, EventArgs e)
{
var label = (Label)this.Form.FindControl("myLabel");
label.Text = "test success!";
}
}