Link to home
Start Free TrialLog in
Avatar of recruitit
recruitit

asked on

Hiding an ASP.NET Image Control from Javascript

Hello everyone!

Got a really irritating problem that just wont quit.

I am trying to hide an <asp:image> control from javascript.

What I basically have are the following three components

asp:ImageMap
asp:RectangleHotSpot
asp:Image

Now, the asp:Image is an overlay to the ImageMap.  It starts with Visible set to false.
When the user clicks the RectangleHotSpot, I want to make the asp:image visible.

I have setup my asp:ImageMap to use HotSpotMode="Navigate".
The asp:RectangleHotSpot has the navigation url set to "javascript:flipImageVisibility('1');"

Each hotspot will have its own value that it imputs into the flipImageVisibility function.

The javascript function is defined below in the code part.

What essentially happens is that document.getElementById always returns null.  I have tried using the exact id, as well as the objectid.ClientID.  Both always return null.

Anyone know what could possibly be wrong?

Thanks!
function flipImageVisibility(id) {
			        
			        switch (id) {
			            case "1":
			                document.getElementById('<%=imgOverlay1.ClientID%>').Visible = 
! document.getElementById('<%=imgOverlay1.ClientID%>').Visible;
			                break;
			        }
			        
			    }

Open in new window

SOLUTION
Avatar of mohan_sekar
mohan_sekar
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of recruitit
recruitit

ASKER

I used style.display = 'none' in the end.