Solved

angular asp.net button prevent button from submitting

Posted on 2014-03-17
1
809 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
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…

695 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