In the following code when I click on my Clear_Button
my OnClick
event refreshes my page and I don't want that to happen. How can I prevent this from happening?
<dx:ASPxButton ID="Clear_Button" runat="server" AutoPostBack="false" CssClass="bordered-orange roundCorners toRight toMiddle" Text="Clear" Width="18%" Theme="Metropolis">
</dx:ASPxButton>
My Event :
Protected Sub Clear_Button_Click(sender As Object, e As EventArgs)
Author.Items.Clear()
End Sub
Thank you in advance for your answers
event.preventDefault(); will work
Try to use in frontend like javascript to clearing your data or refreshing your page without postback
<asp:Button ID="Clear_Button" runat="server" CssClass="bordered-orange roundCorners toRight toMiddle" Text="Clear" Width="18%" Theme="Metropolis" OnClientClick="return resetButtonClick();"Text="Reset" />
<script type="text/javascript"> function resetButtonClick() { $("#<%= txt1.ClientID %>").val("");$("#<%= txt2.ClientID %>").val(""); return false;}</script>
<script type="text/javascript"> function resetButtonClick() { $("#<%= txt1.ClientID %>").val("");$("#<%= txt2.ClientID %>").val(""); return false;}</script>
To prevent refresh, you can use:
<dx:ASPxButton ... OnClientClick="return false;" >
</dx:ASPxButton>
thank you for your answers !
I managed to make it work thanks to the <asp:updatepanel>
element which allows not to refresh the page
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.