Hidalgo
Hidalgo

Reputation: 941

How to use HTML button tag with ASP.Net server side click event?

The following link shows examples of Bootstrap Modal dialogs. Some examples have button (e.g. Send Email). http://getbootstrap.com/javascript/#modals

If the Modal dialog is on an .aspx form, is it possible to call a method (code behind in .aspx.cs) when user clicks on a button of the modal?

I tried changing the button as follows but it didn't produce any result

<button type="button" runat="server" class="btn btn-primary" onclick="Submit_click">Email</button>

That is the code in method Submit_click never fires.

Upvotes: 1

Views: 3023

Answers (1)

Win
Win

Reputation: 62260

I personally like using ASP.Net Server control if possible.

<asp:Button runat="server" ID="Button1" CssClass="btn btn-primary"
   OnClick="Submit_click" Text="Email"/>

If you really want to use button tag, you need to use OnServerClick

<button type="button" runat="server" class="btn btn-primary" 
   OnServerClick="Submit_click">Email</button>

Upvotes: 2

Related Questions