Solved

angular asp.net button prevent button from submitting

Posted on 2014-03-17
1
794 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying 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

Suggested Solutions

Title # Comments Views Activity
null, truthy, falsey confusion 25 33
Selenium and Xpath 4 35
C# Get Current Exchange Rate from XE 9 15
ComboBox to String Not Working 5 20
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

726 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