Cancelling client-side LinkButton OnClick event doesn't work in IE (but works in Firefox)


I have a number of LinkButtons in use on a site that might need to have their click events cancelled for some reason (client-side). I'm finding that the event isn't getting cancelled in IE7, but it does in Firefox.

To see the problem in action:

1) Visit

2) Type "ios" into the "Location:" search box

3) CLICK the "Search for activities" button (do not press [enter] as this runs different client side code that works as it's not under the LinkButtons control)

The client-side code should prevent the button from causing a postback, but fails to do so on IE7.

Anyone have any idea why it isn't working as expected? Any help would be greatly appreciated.

Cheers, Gavin.


Useful info:

.NET Framework being used = 3.5

Code executed when button is clicked:


function CheckForMinLocationSearchCriteria(ctrlCountryFilterID,ctrlKeywordID,msg)
var ctrlCountry=document.getElementById(ctrlCountryFilterID);
var ctrlKeyword=document.getElementById(ctrlKeywordID);
if(ctrlCountry.value.length < 2 && Trim(ctrlKeyword.value).length > 0 && Trim(ctrlKeyword.value).length < 5)
return false;
else { return true;
Gavin Harriss
5/9/2008 1:19:58 AM 93655 articles. 6 followers. Follow

3 Replies

Similar Articles

[PageSpeed] 1

does the Alert message shows in the browser? 


"Code, Beer and Music" that's my way of being a programmer!

How to get your Forum Question Answered | Blog | CodeASP.NET
5/9/2008 3:27:49 AM

Yes the message shows, but IE7 seems to ignore the return value. There's a few other similar bits of code in about 5 different areas of the website that have the same problem with IE7 but work fine when tested in Firefox.

Gavin Harriss
5/9/2008 3:44:02 AM

For the benefit of anyone else who stumbles upon this thread with a similar problem, the solution...

It seems that IE7 didn't like my OnClientClick JavaScript. Changing my code from:

lbSearch.OnClientClick = "if(!((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))){return CheckForMinLocationSearchCriteria('" & Me.ddlLocCountry.ClientID & "','" & Me.txtLoc.ClientID & "',sMinLocationSearchCriteriaErr);}" 


lbSearch.OnClientClick = "if(!((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13))){return CheckForMinLocationSearchCriteria('" & Me.ddlLocCountry.ClientID & "','" & Me.txtLoc.ClientID & "',sMinLocationSearchCriteriaErr);}else return false;

Solves the problem. 

Gavin Harriss
5/11/2008 8:19:08 PM

Similar Artilces:

onClick event doesn't fire in IE (works great in Firefox)
Hi everyone. I'm stumped. I have a simple .NET form. Some fields with validation and a submit button. On clicking the submit button, an email gets fired off containing the submitted field values and the user gets redirected to another page. This process works as it should in Firefox, but in IE 7 nothing happens. No redirect, no JavaScript errors. Nothing.My button code:<asp:Button ID="cmdSubmit" runat="server" Text="Submit" CausesValidation="true" OnClick="cmdSubmit_Click" /> My code behind function:protected void cmdSubmit_Cli...

Can't cancel LinkButton click event in OnClientClick in IE (works in Firefox)
Hi, I was wondering if any client-side development guru out there could shed any light on my issue...I have a LinkButton on a form which only allows a postback to occur when a minimum level of search criteria has been added. However, I don't seem to be able to cancel the click in IE (but it works as expected in Firefox).VB.NET code:lbLocSearch.OnClientClick = "var rtn=false;if(CheckForMinLocationSearchCriteria('" & ddlLocCountry.ClientID & "','" & txtLocSearch.ClientID & "',sMinLocSearchCriteriaErr)){ClearButtonHtml();rtn=true;}els...

TreeView in IE works doesn't work in FireFox
I have a treeview that works great in IE, but it doesnt work in FireFox. It gives an extra space and a link to a __doPostBack function. Here is the source code from each:from FireFox: <tr class="FreeText">  <td id="_tdManagersTree" align="left" colspan="4">     <div class="SubHeadingBackground" id="_tvManagers" class="SubHeadingBackground">      <table CELLSPACING="0" CELLPADDING="0" BORDER="0">           <TR>        ...

Collapsible Panel doesn't work in IE with MasterPage (Works in FireFox)
Hi, I have a collapsible panel extender inside a content page using a masterpage <asp:Content ID="Content1" ContentPlaceHolderID="cphPageLayoutContentPlaceHolder" runat="server"> <toolkit:CollapsiblePanelExtender ID="cpeFiltersPanel" runat="server" TargetControlID = "pnlFilters" ExpandControlID = "pnlFiltersHeader" CollapseControlID = "pnlFiltersHeader" Collapsed="true" ImageControlID="imgUpDownArrow" ></toolkit:CollapsiblePanelExtender> This code works in FireFox but not in IE. The collapsible panel works without the masterpage The problem is it doesn't work with I...

CSS style doesn't work in IE, works in firefox, preview
Hi, I am using a CSS file for most of the styling on one of my webpage. When I make a modification to the font size, nothing changes in IE.  The new font size is appears in my design preview and in Firefox.  Does anybody know what could cause that ??Thansk, Max  Post your CSS so we can see what might be the problem. I've never encountered a problem where IE blatantly disregarded a font-size change, so I wouldn't know offhand what the issue is....

JavaScript Calendar Doesn't work in Firefox but works fine in IE
Hello, I am trying to implement a javascript based pop-up calendar in my web app and also add some ATLAS functionality. The calendar works fine in IE 6.0 but just pops-up in Firefox (ver and does nothing else.  As soon as I remove the ATLAS Scriptmanager tag, and all other ATLAS update panels, it work fine.  Here is a sample of the page code without the ATLAS code:<%@ Page Language="VB" AutoEventWireup="false" CodeFile="MISys.aspx.vb" Inherits="MISys" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transit...

<br/> doesn't work with Firefox (work in IE)
 Here is an example of my code:<ajaxToolkit:TabPanel ID="TabPanel5" runat="server" HeaderText="CDE" >                <HeaderTemplate>                    General <br /> Marketing  "General Marketing" showed as 1 line with firefox... How can I fix this problem?Plz HelpThanks.  Hi Davidvoyage, Same control sometimes may have different beh...

usercontrol events doesn't work on web form
my usercontrol have two kind of events- ImageButton7.Attributes.Add("onmouseout", "src='images/link1.gif'") to change appearence while moving the mouse, and response.redirect to limk to other sites. both doesn't work in the web form! how can make them work, with recoding every page? What happens when you "mouseout" from ImageButton7? Does nothing at all happen? Or is it swapped for the "missing image" symbol? And how are you trying to response.redirect? If you're adding this in the same way as you've added the onmoueout script, then it wo...

registration script doesn't work using IE but works fine using firefox
Hi its an / c# script which was working fine till about few days ago when suddenly it stopped. I know it is something to do with the validation script which runs at server but I can't figure out what had happened to stop it working. I have two sections for registration ... free and pay parts the free section give an error after filling the form and click register, the error I get is an invalid email address ... the pay registration form just doesn't do anything when filling the form and click register .. here is the a snipet of the code in the free registration section....

Simple Web Service: IE works firefox doesn't
[Exception... "'Sys.ArgumentNullException: Sys.ArgumentNullException: Value cannot be null. Parameter name: element' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001c (NS_ERROR_XPC_JS_THREW_JS_OBJECT)" location: "<unknown>" data: no] undefined Sys.ArgumentNullException: Value cannot be null. Parameter name: element  {name: "handler", type: Function}   Scriptresource.asxd file line 3020   3011Sys.UI.DomEvent.registerClass('Sys.UI.DomEvent'); 3012 3013var $addHandler =...

Spellchecker doesn't work: no error, just doesn't work
Hey all. This is only happening with one person. It's all GW7 no SP. has worked fine before. Anyway when they type along it doesn't catch that spelling and it doesn't fire up spell check before it's sent like it is checked off to do. It does nothing. It just sends it when you click send; no error, nothing. I did a rebuild, analyze/fix. I have it set at all levels for this user. any ideas Mark, well, I'd try a more recent client version first. GW7 was less than stellar before SP1. Uwe -- Novell Support Connection Volunteer SysOp Please don...

Urgent: AutoCompleteExtender doesn't work/Updatepanel doesn't work
This is my code for the AutoCompleteExtender <asp:textbox id="txtQuickSearch" runat="server" CssClass="inputText" style="width:145px; "></asp:textbox> <atlas:AutoCompleteExtender runat="server" ID="acSearch"> <atlas:AutoCompleteProperties TargetControlID="txtQuickSearch" Enabled="True" ServicePath="http://localhost/Sony.BusinessSuite.Web.UI/AtlasServices/MasterData.asmx" ServiceMethod="GetAllModels" minimumprefixlength="2" /> </atlas:AutoCompleteExtender> When i start typing fiddler shows: # Result Host URL Body Caching Content-Type User-...

Following java script doesn't work in IE but works fine in firefox any help appreciated
See below code here i am calling the open function . it gives me the value of the text in firefox but in IE it says "undefined"  function open(obj) { var txt = obj.text; alert(txt); } <asp:TemplateField HeaderText="Page ID"> <ItemTemplate> <asp:LinkButton ID="lnkPageID" runat ="server" OnClientClick="open(this);return false;&quo...

System.web.UI doesn't work in VB.Net Form?
 Hi, I downloaded a little example recently and tried converting it to VB.Net.  Surprisingly I found that while my VB Web projects and CSharp Windows Form projects work with System.web.UI, VB Windows Forms don't seem to. Is there any way I can use System.web.UI features with a windows form? This is the code I'm trying to convert to VB:   using System.IO;using System.Web.UI.WebControls;using System.Web.UI;// render the DataGrid control to a fileusing(StreamWriter sw = new StreamWriter(textBox1.Text)){ using(HtmlTextWriter hw = new HtmlTextWriter(sw)) { g...

Web resources about - Cancelling client-side LinkButton OnClick event doesn't work in IE (but works in Firefox) -

Client-side scripting - Wikipedia, the free encyclopedia
... different and changing content depending on user input, environmental conditions (such as the time of day), or other variables. Client-side ...

Senior Search Manager - Client Side!!
... strategy insight for senior IT management - resources to understand and leverage information technology. Senior Search Manager - Client Side ...

Account Manager - Client Side - Previous Agency Experience Welcome!!
Computerworld Australia is the leading source of technology news, analysis and tools for IT decision makers, managers and professionals.

Media Sales Executive - Client Side!!
Technology news and reviews for business and home.

PPC Paid Search Manager - CLIENT SIDE
Defining Technology for Australia's IT Leaders. PPC Paid Search Manager - SEM - **CLIENT SIDE** Sydney CBD Location Client side!! SEM/PPC/Paid ...

How Basecamp Next got to be so damn fast without using much client-side UI
When we started working on Basecamp Next last year, we had much internal debate about whether we should evolve the existing code base or rewrite ...

Seven Tips for Pitching From the Client's Side of the Table
I had a chance to sit on the other side of the pitch table. Here is what I learned.

Client-side coding: How to prevent malicious use?
Applications that run on a user-controlled device cannot be perfectly protected.

The client side
... regarding the professionals you seek to assist. Even better if you possess that understanding yourself, having worked on the client side. I'm ...

Ecommerce traffic being hijacked by client side malware
According to new research 15 to 30 percent of eCommerce site visitors are infected with Client Side Injected Malware (CSIM) that causes them ...

Resources last updated: 12/6/2015 10:34:55 PM