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
是解决此问题的最佳方法,但如果我有80个按钮,那么我必须将txt.Text = String.Empty
置于80按钮中事件。有没有更好的方法呢?