如何清除文本框 [英] how to clear the textbox

查看:147
本文介绍了如何清除文本框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我是asp.net的新手,这个问题似乎很傻,但是我真的不知道出什么问题了.

我在清除文本框时遇到问题.
我尝试了textbox.text=string.emptytextbox.text="",但是这些似乎都没有帮助,只是没有清除文本框.

有人可以告诉我是否在代码中设置了不允许我清除文本框的内容吗?


Hi,

I am new to asp.net.and this question seems pretty silly, but I really can''t figure out what is wrong.

I am having an issue with clearing the textbox.
I tried textbox.text=string.empty, textbox.text="" but none of these seem to help, the textbox just doesn''t get cleared.

Can someone tell me if I have set something in the code that''s not allowing me to clear the textbox?


<asp:TextBox ID="TextBox3" runat="server" Width="177px" ontextchanged="TextBox3_TextChanged" Height="16px" style="margin-left: 5px"></asp:TextBox> 





protected void Button11_Click(object sender, EventArgs e)
{
  Panel1.Visible = false; DropDownList5.ClearSelection();
  TextBox3.Text = string.Empty;
}


[/Edit]


[/Edit]

推荐答案

:) Txtbxclearfilesafter.Clear(); :)

写完ur文本框的名称后,用txtbxclearfile代替…….
:) Txtbxclearfilesafter.Clear(); :)

in place of txtbxclearfileafter write the name of ur textbox.......


问题对我来说看起来很奇怪..,

可能是您未将所有控件设置为运行服务器

这是我在PC上完成的代码

Problem Looking Strange For me..,

May be your all controls not set as runat server

here is the code i am providing just done on my PC

protected void Button1_Click(object sender, EventArgs e)
 {
     TextBox1.Text = String.Empty;
     TextBox2.Text = String.Empty;
 }




HTML代码




HTML Code

<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:TextBox ID="TextBox2"

            runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server"

            Text="Button" onclick="Button1_Click" />
    </div>
    </form>
</body>




它对我有用....




It''s working For me....


protected void Button1_Click(object sender, EventArgs e) 
{
Textbox1.Text="";//this for clear the text box
DropDownList1.ClearSelection();
}//this for clear thr dropdownlist  


这篇关于如何清除文本框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆