Click here to Skip to main content
12,552,431 members (27,449 online)
Rate this:
Please Sign up or sign in to vote.
See more: IE7 ASP.NET Javascript
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

Posted 11-Oct-12 20:28pm
Updated 11-Oct-12 23:02pm
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
Please Sign up or sign in to vote.

Solution 1

var btn = document.getElementById('<%=btnDummy.ClientID%>');;
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);

Hope it helps.

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 | Mobile
Web02 | 2.8.161021.1 | Last Updated 12 Oct 2012
Copyright © CodeProject, 1999-2016
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