• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 846
  • Last Modified:

angular asp.net button prevent button from submitting

I have a button on an angular view that is loaded on a page.  It isn't an asp.net button.  How can I prevent it from submitting? It will hit my angular function, but it always submits.  If I use a div instead of a button, my function executes.

<button ID="emailSend" Class="emailSend floatRight buttonStyle" ng-click="SendEmail()">Send</button>
                <br/>
<div ng-click="SendEmail()" style="border:1px solid red;">Send</div>

Open in new window


These both call the SendEmail function in the controller.  The button isn't an asp.net control and doesn't have a runat="server".

This is from my controller
$scope.SendEmail = function () { alert("It Works"); };

Open in new window

0
jackjohnson44
Asked:
jackjohnson44
1 Solution
 
leakim971PluritechnicianCommented:
Add type="button" to your button

Test page : http://jsfiddle.net/Tdpzs/1/

<button ID="emailSend" Class="emailSend floatRight buttonStyle" ng-click="SendEmail()" type="button">Send</button>

Open in new window

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now