Célio Pereira
Célio Pereira

Reputation: 61

Asp.net buttons event click without do postback. Is it possible?

I would like to know if is possible to use a asp:button, use an event click. and call a javascript instead code behind without to do postback? I need to record voice and I´m using javascript to do this. Someone could help me?

Upvotes: 1

Views: 994

Answers (1)

Cesar Loachamin
Cesar Loachamin

Reputation: 2738

You could create your button and use the OnClientClick Property in this way:

<asp:Button runat="server" Text="Click me" OnClientClick="myFunction(); return false;" />

With that you call myFunction(); and the return false; prevent the __doPostBack function will be called avoiding the postback.

Upvotes: 1

Related Questions