?
Solved

client side button confirm not working

Posted on 2008-06-18
2
Medium Priority
?
273 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
[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
2 Comments
 
LVL 16

Accepted Solution

by:
ororiole earned 2000 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

RHCE - Red Hat OpenStack Prep Course

This course will provide in-depth training so that students who currently hold the EX200 & EX210 certifications can sit for the EX310 exam. Students will learn how to deploy & manage a full Red Hat environment with Ceph block storage, & integrate Ceph into other OpenStack service

Question has a verified solution.

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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
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…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

762 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