Solved

client side button confirm not working

Posted on 2008-06-18
2
267 Views
Last Modified: 2013-12-16
For some reason my client side button confirm is not working.  I'm using IE7, windows vista, and I have duplicated this in both VS 08 and VS 05, and neither work.  When I click the button, the confirm shows up, but when I click cancel, the page still posts back.  What am I missing?!?!?!?!
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" />
    </div>
    </form>
</body>

public partial class _Default : System.Web.UI.Page {
    protected void Page_Load(object sender, EventArgs e) {
        Button1.Attributes["onclick"] = "javascript:return confirm('dffddads');";
    }
}
0
Comment
Question by:ARACK04
2 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 500 total points
ID: 21818909
change it to
Button1.Attributes["OnClientClick"] = "javascript:return confirm('dffddads');";

onclick is in the end a server side event so it is going to postback by default. You want this to be a client side event so use OnClientClick.
0
 

Author Comment

by:ARACK04
ID: 21818922
Nope, the answer is here, but thanks.

http://www.developerfusion.co.uk/forums/p/36114/165895/#165895 
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

932 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

12 Experts available now in Live!

Get 1:1 Help Now