1. 不能不触发, but tryvoid Page_Load(Object o, EventArgs e)
{
if (!IsPostBack)
{
//your initialization code goes here
}
}
2. >>>清空所以文本框
assume 文本框 are direct children of form1
<form id="form1" runat="server">
<asp:TextBox ...>
</form>...
foreach (Control c in form1.Controls)
{
if (c is TextBox)
{
((TextBox)c).Text = "";
}
}
{
if (!IsPostBack)
{
//your initialization code goes here
}
}
2. >>>清空所以文本框
assume 文本框 are direct children of form1
<form id="form1" runat="server">
<asp:TextBox ...>
</form>...
foreach (Control c in form1.Controls)
{
if (c is TextBox)
{
((TextBox)c).Text = "";
}
}
清空文本框可以用思归的例子,我不懂vb.net,没法给出代码!
if not IsPostBack then
'your initialization code goes here
end if
end sub
2. >>>清空所以文本框
assume 文本框 are direct children of form1
<form id="form1" runat="server">
<asp:TextBox ...>
</form>...
dim c as Controlfor each c in form1.Controls
if (TypeOf(c) is TextBox) then
CType(c, TextBox).Text = ""
end if
next
<asp:TextBox ...>
...
</form>if you are using code-behind, declare in your Page class
protected form1 as HtmlForm
so i make it global sub as following:
public sub cleartexts(byval frm as HtmlForm)
dim c as Controlfor each c in frm .Controls
if (TypeOf(c) is TextBox) then
CType(c, TextBox).Text = ""
end if
end subnow,i invoke it as following:protected form1 as HtmlForm
call cleartexts(form1)but it occurs error as following:未将object 引用 到 instance.what should i do?
<form id="what" method="Post" runat="server">把:
protected form1 as HtmlForm
换为:
protected what as HtmlForm
thank timmy3310(tim) and saucer