Sub clear_click( s As object, e As EventArgs )
Dim ctlControl As Control
Dim txtTextBox As TextBox For each ctlControl in Controls
If Typeof ctlControl Is TextBox Then
txtTextBox = ctlControl
txtTextBox.Text = ""
End IF
Next
End Sub我的目的是想把页面中的TEXTBOX中的内容清空,请问各位为什么不行呢,?要实现这个目的,还有什么其它方法,谢谢!
Dim ctlControl As Control
Dim txtTextBox As TextBox For each ctlControl in Controls
If Typeof ctlControl Is TextBox Then
txtTextBox = ctlControl
txtTextBox.Text = ""
End IF
Next
End Sub我的目的是想把页面中的TEXTBOX中的内容清空,请问各位为什么不行呢,?要实现这个目的,还有什么其它方法,谢谢!
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm3</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
<script language="javascript">
function chksubmit()
{
var mm = document.getElementsByTagName("input").length;
for(var i=0; i<mm; i++)
{
var dd = document.getElementsByTagName("input").item(i);
if(dd.type == "text")
{
dd.value = "ok, change this to null.";
}
}
}
</script>
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<FONT face="宋体"><INPUT style="Z-INDEX: 101; LEFT: 136px; POSITION: absolute; TOP: 88px" type="text">
<INPUT style="Z-INDEX: 102; LEFT: 128px; POSITION: absolute; TOP: 48px" type="text">
<INPUT style="Z-INDEX: 103; LEFT: 136px; POSITION: absolute; TOP: 128px" type="text">
<INPUT style="Z-INDEX: 104; LEFT: 128px; POSITION: absolute; TOP: 208px" type="button"
onclick="chksubmit();" value="aaaaaaaaaaaa"></FONT>
</form>
</body>
</HTML>
调用:<script>window.opener.form1.Password.value="";</Script>还有一种方法,就是利用autocomplete
Sample 1:普通情况,即默认情况,AutoComplete时打开的。见:IE5-工具-内容-自动完成选项。
<form>
<input type = text name = Email>
</form> Sample 2:有时候我们并不需要AutoComplete,例如需要用户自己再次输入密码而非自动完成。只要将所在表单元素的autocomplete属性设置为off即可。
<form>
<input type = password name = Password autocomplete = "off">
</form>Sample 3:那么,如果所有表单元素都不想使用autocomplete功能呢?见下面的方法:
<form autocomplete = "off">
<input type="text" name="textfield">
</form>
<INPUT onclick="ClearData()" type="button" value="重置">
然后用的javascript脚本
<script language="javascript">
function ClearData()
{
document.getElementById("txtTrueName").value="";
document.getElementById("txtQuestion").value="";
document.getElementById("txtAnswer").value="";
document.getElementById("txtFirstEmail").value="";
document.getElementById("txtSecondEmail").value="";
}
我的是C#语言,不知道对你有没有用啊