Solved

client side button confirm not working

Posted on 2008-06-18
2
268 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

778 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