Page_Unload 事件是否有可能重置 textbox.text?我发现不能!
标记
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txt" runat="server"></asp:TextBox>
<asp:Button ID="btn" runat="server" Text="Do something1" />
<asp:Button ID="btn1" runat="server" Text="Do something2" />
<asp:Button ID="btn2" runat="server" Text="Do something3" />
</div>
</form>
</body>
</html>
背后的代码
Protected Sub btn_Click(sender As Object, e As System.EventArgs) Handles btn.Click
Method1()
End Sub
Protected Sub btn1_Click(sender As Object, e As System.EventArgs) Handles btn1.Click
Method2()
End Sub
Protected Sub btn2_Click(sender As Object, e As System.EventArgs) Handles btn2.Click
Method3()
End Sub
Private Sub Method1()
'Do something
End Sub
Private Sub Method2()
'Do something
End Sub
Private Sub Method3()
'Do something
End Sub
Protected Sub Page_Unload(sender As Object, e As System.EventArgs) Handles Me.Unload
txt.Text = String.Empty
End Sub
你可能认为把txt.Text = String.Empty
in each 方法放入是解决这个问题的最好方法,但是如果我有 80 个按钮,那么我必须放入txt.Text = String.Empty
80 个按钮的点击事件。有没有更好的方法来做到这一点?