如何清除页面上的所有输入文本 [英] How do I clear all imput text on page
本文介绍了如何清除页面上的所有输入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的代码无法识别Gettype文本框
我尝试过:
My code does no recognize Gettype textboxes
What I have tried:
Dim ctrl As Control
For Each ctrl In Me.Controls
If (ctrl.GetType() Is GetType(TextBox)) Then
Dim txt As TextBox = CType(ctrl, TextBox)
txt.Controls.Clear()
End If
Next
我的HTML代码......
My html code...
<div>
Doctor :<input type="text" runat="server" name="DoctorName" size="20" class="TxtBox" id="txtDoctorName" tabindex="3" />
<input type="text" runat="server" name="DoctorAddress" size="20" id="txtDoctorAddress" class="TxtBox" tabindex="4" />
<input type="text" runat="server" name="SuiteAddress" size="20" id="txtSuiteAddress" class="TxtBox" tabindex="5" />
<input type="text" runat="server" name="City" size="20" id="txtCity" class="TxtBox" tabindex="6" />
<input type="text" runat="server" name="State" size="5" id="txtState" class="TxtBox" tabindex="7" />
<input type="text" runat="server" name="Zip" size="10" id="txtZipCode" class="TxtBox" tabindex="8" />
<br />
推荐答案
原因是不起作用是因为你正在测试Windows.Forms.Controls.TextBox而不是WebForms TextBox。
要清除网页上的所有输入控件,只需使用简单的jquery:
The reason is doesn't work is because you are testing against the Windows.Forms.Controls.TextBox instead of the WebForms TextBox.
To clear all input controls on a webpage just use simple jquery:
// Clear all textboxes
( input [type = text],textarea)。val(' ');
("input[type=text],textarea").val('');
我不知道我的html代码是不是让我的代码落后工作或没有。
我尝试将类型从文本更改为文本框但我收到错误
I don't know if my html code is not letting my code behind to work or not.
I tried changing type from "Text" to "Textbox" but I get an error
这篇关于如何清除页面上的所有输入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文