javascript in button click event?
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
Change onClick to OnClientClick
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.
精彩评论