Reputation: 30303
i place the onClick event in asp buttons. but it is showing error like
Too many characters in character literal
my code is
<asp:Button ID="Button1" runat="server" Text="Button"
onClick="alert('The button was clicked.');" />
actually my requirement is when i click on the button i want to display some message and when we press ok then it is redirect to another page is it possible
thank you
Upvotes: 0
Views: 782
Reputation: 11442
You need to use the OnClientClick method, OnClick is the server side event. e.g.
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="return confirm('are you sure');" />
This code produces a message box which if cancelled, prevents the server-side event from being fired. If you click 'OK' to the message box the server event is fired as usual and you can then do your redirect as necessary.
Upvotes: 1