zoukankan
html css js c++ java
asp.net动态添加控件
using
System;
using
System.Data;
using
System.Configuration;
using
System.Collections;
using
System.Web;
using
System.Web.Security;
using
System.Web.UI;
using
System.Web.UI.WebControls;
using
System.Web.UI.WebControls.WebParts;
using
System.Web.UI.HtmlControls;
public
partial
class
Default3 : System.Web.UI.Page
{
public
bool
IsDynamicLoadControl
{
get
{
object
dynamic
=
ViewState[
"
IsDynamicLoadControl
"
];
return
dynamic
==
null
?
false
:
true
;
}
set
{
ViewState[
"
IsDynamicLoadControl
"
]
=
value;
}
}
protected
override
void
LoadViewState(
object
savedState)
{
base
.LoadViewState(savedState);
if
(IsDynamicLoadControl)
{
LoadTextBox();
}
}
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(
!
IsPostBack)
{
LoadTextBox();
}
}
private
void
LoadTextBox()
{
for
(
int
i
=
0
; i
<
10
; i
++
)
{
TextBox input
=
new
TextBox();
input.ID
=
"
input
"
+
i.ToString();
this
.form1.Controls.Add(input);
}
IsDynamicLoadControl
=
true
;
}
protected
void
Button1_Click(
object
sender, EventArgs e)
{
TextBox tb
=
this
.FindControl(
"
input0
"
)
as
TextBox;
Page.ClientScript.RegisterStartupScript(
this
.GetType(),
""
,
string
.Format(
"
<script>alert('{0}')</script>
"
, tb.Text));
}
}
查看全文
相关阅读:
每日立会2015-11-30
Some Modern Softwares' drawbacks: User experience 12/29/2015
Sprint 5 summary: UI 界面更新,Azure端部署和用户反馈分析 12/28/2015
Daily Scrum 12/25/2015
Daily Scrum 12/24/2015
Daily Scrum 12/23/2015
Daily Scrum 12/21/2015
Daily Scrum 12/18/2015
Daily Scrum 12/17/2015
Performance standard (ALPHA release) 12/17/2015
原文地址:https://www.cnblogs.com/bobofsj11/p/1597807.html
最新文章
四则运算程序
作业
Daily Scrum- 12/31
Daily Scrum- 12/28
Daily Scrum 12-25
测试计划
Daily Scrum- 12/23
测试计划
What’s for Beta
Daily Scrum
热门文章
Daily Scrum
stand up meeting 12-11
stand up meeting 12-10
stand up meeting 12-9
stand up meeting 12-8
stand up meeting 12-7
stand up meeting 12-4
stand up meeting 12-3
stand up meeting 12-2
每日立会2015-12-01
Copyright © 2011-2022 走看看