以下是我是目前的理解:有錯誤請指正
(1)一般用法:按Button1後執行的動作是Submit,執行Button1_Click,此時預設值UseSubmitBehavior="true"
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />
(2)加入UseSubmitBehavior="false"用法:按Button1後執行的動作是一般的Button,執行Button1_Click
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" UseSubmitBehavior="false" />
(3)加入UseSubmitBehavior="false"和OnClientClick用法:按Button1後執行的動作是一般的Button,先執行OnClientClick後再執行Button1_Click
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" UseSubmitBehavior="false" OnClientClick="this.disabled=true;this.value='Saveing...';" />
(4)OnClientClick用法:按Button1後執行的動作是一般的Button,先執行OnClientClick後再執行Button1_Click,如果在OnClientClick事件發生後卻得到false的訊息,就不會發生PostBack
<asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" OnClientClick="return confirm('Are you sure you want to submit this form?');" />
沒有留言:
張貼留言