Solved

client side button confirm not working

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

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…
A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

706 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

18 Experts available now in Live!

Get 1:1 Help Now