更改按钮的值和文本
我有一个文本框和一个连接有 onClick 事件的按钮,当单击该按钮时,我想更改按钮的文本并清除文本框。我怎样才能做到这一点?
I have a textbox and a button with an onClick event connected to it, and when the button is clicked once I want to change the text of the button and clear the textbox. How can i accomplish this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您想在回发(页面的完全刷新)上执行此操作,只需将代码放入按钮单击处理程序中即可设置这些值。例如,
textbox.Text = string.Empty;
如果您想在客户端设置它(不刷新页面),那么您需要使用客户端脚本,例如 JavaScript。
If you want to do this on a postback (a complete refresh of the page), simply put code in your button click handler to set these values. For example,
textbox.Text = string.Empty;
If you want to set it on the client side (without refreshing the page), then you'd need to use client script such as JavaScript.
这需要您了解 TextBox 及其属性。通常,文本框的值使用其 Text 属性作为 TextBox1.Text。在您的情况下,您将此语句放在按钮的单击事件中
以查看如何使用 TextBox 及其属性。 这会有所帮助
This needs you to know about TextBox and its properties. Normally the value of a textbox you use its Text property as TextBox1.Text. In your case you put this statement in the button's click event
To see how to use TextBox and its properties. This can help