【问题标题】:Remove default text after clicking in the TextBox in c#在C#中单击TextBox后删除默认文本
【发布时间】:2016-04-06 09:19:33
【问题描述】:

当您激活应用程序时,会出现一个带有文本“[Hello]”的文本框。

当你点击文本框输入数据时,我想在c#代码中自动删除文本,我该怎么做?

<asp:TextBox ID="txtM" runat="server" Text="[Hello]"></asp:TextBox>

你能帮我解决问题吗?

提前致谢。

【问题讨论】:

    标签: c# textbox onclick


    【解决方案1】:

    很简单,看这个!

    http://dotnetdrizzles.blogspot.it/2015/03/how-to-clear-textbox-value-when-user.html

    <asp:TextBox ID="txtName" runat="server" 
      onclick="if (this.value == 'Enter Name') {this.value='' ;this.style.color = 'black'}" 
        onblur="if(this.value.length==0) { this.value='Enter Name';this.style.color = 'grey'}" 
            Width="275px" ForeColor="#999999">Enter Name</asp:TextBox>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-02-28
      • 2011-10-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-20
      • 1970-01-01
      相关资源
      最近更新 更多