Solved

angular asp.net button prevent button from submitting

Posted on 2014-03-17
1
784 Views
Last Modified: 2014-03-18
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
Comment
Question by:jackjohnson44
1 Comment
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39935811
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question