Click here to Skip to main content
13,199,852 members (60,753 online)
Rate this:
 
Please Sign up or sign in to vote.
I have written code like,

document.getElementById("<%= btnVillageSearch.ClientID %>").click();


To Perform Click Operation which working in Mozilla Firefox, But while coming to IE,

It is not supporting. Please tell me how to perform button click from Java Script for

IE.
Posted 11-Oct-12 20:28pm
Updated 11-Oct-12 23:02pm
DaveAuld193.7K
v2
Comments
Aman.A 12-Oct-12 2:56am
   
Are u missing a "#" after "<%"? The other thing u could try is set the clientidmode property to static of the button and then access the id directly in your JavaScript as a literal string. See if that works.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

var btn = document.getElementById('<%=btnDummy.ClientID%>');
btn.click();

This is something i have used previously and can confirm it works in IE. , also try moving the the script block to the end of the page, it might also have something to the version of IE you are using.

Or you can try this, this is something i used in Safari which wouldnt otherwise fire the click() event properly
var dispatch = document.createEvent("HTMLEvents")
dispatch.initEvent("click", true, true);
document.getElementById('<%=btnDummy.ClientID%>').dispatchEvent(dispatch);


Hope it helps.
  Permalink  
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web01 | 2.8.171020.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100