Links
Activity
<July 2008>
SunMonTueWedThuFriSat
293012345
6789101112
13141516171819
20212223242526
272829303112
3456789
Blogroll
Archive
Categories
Search
Admin Login
Sign In

Ok, so this isn't so much "Smooth" in the sense that it's a really slick piece of code.  Rather it's "Smooth" because it took me way to long too figure it out and I thought that I better write it down somewhere that google has a chance of indexing it.  That way a month from now when I may have forgotten this, I'll be able to look it up. 

I'm working on this project where I show users an image and they can perform some zoom in type action where they click on the image and drag a rectangle, or they click on a bunch of points to draw lines allowing them to draw their own shape.  This is basically all accomplished with javascript.  Good.  Not hard to figure out.  When they are done drawing their shape, I am clicking on a button in the background (by using javascript) to force a postback so that I can call some web service in the code behind and reload the image.  Note that this isn't a full Page postback, since I'm using an anthem:button.

Ok, so all is well, I get the new image url, I load it up.  Done!  Not quite.  Because in my case, I'm doing some fancy fade in from a placeholder image that lets the user know that something is going on.  Ok, so I need to get back to running some javascript.  Stick it in the window.onload event.  Yeah.....no.  Not so much.  This is where anthem causes a problem because the page isn't actually reloading.  Just my image....which did I mention is an anthem:image?  So the obvious solution now is to put my javascript method call in the image's onload event.  Sounds like a good idea, right?  Well it is, but the only tricky part is, how do you do it?

This doesn't work:

<anthem:image onload="FancyFadeIn()"> </anthem:image>

That's because an anthem:image doesn't play the onload game that way.  BUT if you really know what's going on, you'll know that when everything is said and done that <anthem:image> ends up as an <img> which does have an onload event.  To add that attribute using the Language of the Gods VB.NET, you do something like this:

Me.mapImage.Attributes.Add("onload", "FancyFadeIn()")

Now when the image reloads, the fade in javascript is called and everything is right with the world.

Friday, August 18, 2006 1:45:23 PM (Pacific Daylight Time, UTC-07:00) | Comments [0] |  |  | #
www. flickr .com