如何在 C# 中处理 Web 只读文本框的点击事件
请您参考如下方法:
看看OnClick Event for Text Box in ASP.NET with C# :
indeed TextBox doesn't have Click event at server-side. One reason is that it wouldn't necessarily be reasonable to cause a postback to clear a TextBox (server-side event requires server-side action to occur e.g also a postback).
But, textBox is a web control which supports expando attributes, that is, any attribute added to the control tag which doesn't match any member of the control, is arendered out as is to the markup. So you could in fact use this to create a javascript click action to clear the TextBox. Either set this on aspx
<asp:TextBox ID="TextBox1" runat="server" OnClick="this.value=''"/>or this in code
Me.TextBox1.Attributes("onclick") = "this.value=''"
