如何使用 JavaScript 为 C# 类中的单选按钮控件实现“onclick”事件,以更改隐藏的服务器控件文本框文本值以反映单击了哪个按钮?这些按钮是在客户端上运行的 html 控件。
假设我有 2 个单选按钮:Button1 和 Button2。在我的 C# 代码中,我需要替换下面的警报调用来更新我的 Textbox 控件,此隐藏中的值将在 PostBack 上处理。
Button1.Attributes.Add("onclick", "alert(' You clicked Button 1. How do I update textBox.Text? in here?');");
Button2.Attributes.Add("onclick", "alert('You clicked Button 2. How do I update textBox.Text? in here?');");