473,772 Members | 2,510 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OnClientClick in an asp:LinkButton - using confirm() doesn't work inevery browser

Here's my code:

<asp:LinkButt on
OnClick="Delete File"
OnClientClick=" if (!confirm ('Are you certain you want to delete
this file?') ) return false;"
runat="server"
ID="DeleteButto n">DELETE
</asp:LinkButton>

Now, this works fine in FireFox but in IE7 on Vista it deletes the
file whether the user hits OK or Cancel. Any guidance/ideas?

Thanks!
Dec 14 '07 #1
2 19147
there is a long standing IE bug (since 5.5) where returning false doesn't
cancel the event as it should.

function cancelEvent()
{
// ie hack
if (window.event) window.event.ca ncelBubble = true;
return false;
}

<asp:LinkButt on
OnClick="Delete File"
OnClientClick=" if (!confirm ('Are you certain you want to delete
this file?') ) return cancelEvent();"
runat="server"
ID="DeleteButto n">DELETE
</asp:LinkButton>
-- bruce (sqlwork.com)
"dddan" wrote:
Here's my code:

<asp:LinkButt on
OnClick="Delete File"
OnClientClick=" if (!confirm ('Are you certain you want to delete
this file?') ) return false;"
runat="server"
ID="DeleteButto n">DELETE
</asp:LinkButton>

Now, this works fine in FireFox but in IE7 on Vista it deletes the
file whether the user hits OK or Cancel. Any guidance/ideas?

Thanks!
Dec 14 '07 #2
I use this kind of thing very often and have never had a problem with IE6 or
IE7. The only difference is I create a separate confirmdel() Javascript
function and use something like this.

function confirmdel(delt ype)
{
if (window.confirm ('Are you sure you want to delete this ' + deltype
+ '?') == false)
{
return false;
}
}

On the LinkButton I use OnClientClick=" return confirmdel('fil e');"

HTH
David

"bruce barker" <br*********@di scussions.micro soft.comwrote in message
news:57******** *************** ***********@mic rosoft.com...
there is a long standing IE bug (since 5.5) where returning false doesn't
cancel the event as it should.

function cancelEvent()
{
// ie hack
if (window.event) window.event.ca ncelBubble = true;
return false;
}

<asp:LinkButt on
OnClick="Delete File"
OnClientClick=" if (!confirm ('Are you certain you want to delete
this file?') ) return cancelEvent();"
runat="server"
ID="DeleteButto n">DELETE
</asp:LinkButton>
-- bruce (sqlwork.com)
"dddan" wrote:
>Here's my code:

<asp:LinkButto n
OnClick="Delete File"
OnClientClick=" if (!confirm ('Are you certain you want to delete
this file?') ) return false;"
runat="server"
ID="DeleteButto n">DELETE
</asp:LinkButton>

Now, this works fine in FireFox but in IE7 on Vista it deletes the
file whether the user hits OK or Cancel. Any guidance/ideas?

Thanks!

Dec 14 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
1611
by: Fresh Air Rider | last post by:
Hi Could anyone please give me the syntax for calling a function with more than one parameter from an <asp:LinkButton> ? Many thanks John
17
7387
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the following code fragments in which I want to list through all files on a directory with a link to download each file by passing a filename and whether or not to force the download dialog box to appear.
5
3749
by: Fresh Air Rider | last post by:
Hello Could anyone please explain how I can pass more than one arguement/parameter value to a function using <asp:linkbutton> or is this a major shortfall of the language ? Consider the following code fragments in which I want to list through all files on a directory with a link to download each file by passing a filename and whether or not to force the download dialog box to appear.
5
3298
by: George Durzi | last post by:
I currently have an href inside of an asp:repeater <a href='<%# String.Concat("PDFReader.aspx?id=", DataBinder.Eval(Container.DataItem, "ProductUniqueId")) %>' target="_blank">View</a> Clicking View will open a new browser and load PDFReader.aspx My client would like me to hide the address bar and toolbar on this new
2
2814
by: BobLaughland | last post by:
Hi There, I need a control on my site that is a hyperlink style control, but it must, 1) Have a property that can hold where the hyperlink is pointing to. (e.g. like the NavigateUrl property in the asp:hyperlink control). 2) Also can call my own method when the user clicks on the link (e.g. like the Click event in the asp:linkbutton control).
2
4452
by: =?Utf-8?B?QWxleA==?= | last post by:
I have an asp linkbutton declared as follows: <asp:LinkButton ID="LinkButton1" runat="server" CssClass="tt">ASP Link Button</asp:LinkButton> My CSS classes are declared as follows: a.tt { color:Black; text-decoration: none; border-bottom: 1px dashed Blue;
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10264
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10039
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7461
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4009
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.