Solved

angular asp.net button prevent button from submitting

Posted on 2014-03-17
1
747 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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
This article discusses how to create an extensible mechanism for linked drop downs.
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…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now