Silverlight Cream for January 21 -- #175

One submittal this morning: A presentation page (in French) done in Silverlight

From SilverlightCream.com:
Silverlight Presentation
If I ever had any French skills they're severly lacking now, but I can certainly tell Silverlight when I see it :) This page has some expand-out sections and a 'screen' that has the appearance of being rolled up. Everything takes you to non-Silverlight pages (I think), but I like the Silverlight use, and also some of the small touches, like the tassel on the screen swinging if you right-click :)

Stay in the 'Light!

Silverlight News on Twitter | Silverlight Tagged Web Articles | My Articles | My Tutorials | My Tooltips | SilverlightCream

Silverlight Monday for January 21, 2008 - #3 - Silverlight Loaded and OnLoad Tests

If you've been following along reading my postings, you'll know that I've been casting aspersions about the canvas Loaded= event at least on IE6 and maybe FireFox. I've got a couple Silverlight applications that just are not solidly functional in IE6 and FIreFox (at least) and the only thing that made sense was that Loaded= didn't always fire.

So to finally 'put that to bed', I decided to write a simple little demo to test that, and as long as I was doing so, I included the OnLoad event as well:

Silverlight Loaded and OnLoad Tests


I won't know until I get to the office later this morning, but I'm almost 100% positive that not only does this page show that Loaded= works just fine, but it found my problem as well!

When I ran this from my site, it didn't work. It threw a JS error saying it could not find my OnLoad function. I did view->source and it was very obviously there at the bottom as I expected. I started having some feelings of dejá vu about that, and decided to look deeper.

All my content is stored in SQL, and I have a process to pull out the markup and display it. For 1.0 this works just great, but I'm not sure what I'm going to do in 2.0 (note to self: worry about that later). When I started doing JS with Silverlight, I needed a way to get the JS into the picture, so I used ClientScript.RegisterStartupScript.

Last night I went looking at that method. I'm not sure exactly why, but it was advantageous because I found that function was deprecated and I should be using ClientScriptManager instead! After a bit of fumbling around, I finally ended up with this:

ClientScriptManager csm = Page.ClientScript;
Type cstype = this.GetType();
csm.RegisterClientScriptBlock(cstype, sEvent, sMarkupJS);

'sEvent' is the database ID of the article, and 'sMarkupJS' is the JavaScript for the article. These two are the same as I used previously.

When I deployed that to my site, the OnLoad event started working on the new page. I immediately fired up FireFox and found no issues there

Bottom Line...

I built this page to test Loaded= and OnLoad and find out where the issues were, and it appears, at least initially, that I may have found them... in my code!

The difference is that previously the JS *was* injected, but it was near the bottom of the page, and apparently not fully alive at the time it was needed. Now the JS is near the top. I'll update about this after I test it in IE6 this morning.

Stay in the 'Light!

Silverlight News on Twitter | Silverlight Tagged Web Articles | My Articles | My Tutorials | My Tooltips | SilverlightCream
«January»
SunMonTueWedThuFriSat
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789