Archive for July, 2007

As always this time of year I begun thinking on all the things I want to read, listen, view and code during my summer vacation free time, even though I never get the chance to do all the things I plan to ;-).

So I’ve already bought my PSP extra memory (2GB) and plan to fill it with podcasts, webcasts and videos so I can watch on my free time. Technologies and products that I’m especially interested this summer include : Silverlight, WPF, WCF, Visual Studio 2008, Astoria, Jasper, Linq, .Net 3.5, C# 3.0 etc.

I’ve already begun searching for those but I would be grateful if you could give me a hand by proposing stuff you think I should definitely have a look at.

This content is password protected. To view it please enter your password below:

I know that many of you will argue on the need to put all these technologies to work together, after all they are intended for different sides of the Internet cloud ( on the server, Ajax on the server & client and silverlight on the client). My experience though has shown that nothing is carved in stone when it comes to software development. Imagine for example that you have a nice GridView control (ASP.NET) containing data that you need to update without refreshing the whole page (Ajax) and at the same time display a nice graph of these data using an animated silverlight control. Is this possible and how would you go through with it?

Working on the last few days on a similar project made me realize that such a project is doable but it gets more and more complicated as you cross the server – client boundaries. You must always question your self where the code you’re writing will run and what effect will have. It’s relatively easy, for example, to call a web service from your silverlight control using an Ajax web service proxy but what if your silverlight control depends on your server side web form state? It’s not that easy for example, to change your silverlight chart, after a GridView Ajax postback, caused by selecting a row.

So my two cent (from the work I’ve done) for those of you that wish to engage in such a project are:

  • Use the script manager’s  scripts section to reference the Silverlight.js script file (and any other javascript files you fill like) otherwise you’ll end up with namespace conflicts (Sys is defined both in Ajax and Silverlight).
    <asp:ScriptManager ID="m_scriptManager"
            <asp:ScriptReference Path="javascript/Silverlight.js" />
            <asp:ScriptReference Path="Default.aspx.js" />
            <asp:ScriptReference Path="xaml/Scene.xaml.js" />
  • Don’t put the silverlight control host inside an update panel. I faced several timing issues, when I tried it, with the createSilverlight method. You can always write the object tag manually and avoid the createSilverlight method and thus the timing issues (I didn’t try it, I’m only guessing that it will work) but then you’ll loose all the functionality provided by the Silverlight.js script file (error handling, version checking, event hooking etc.). After all silverlight is a client control and does not need to be updated through a postback wether that is an Ajax one or not you can update it using javascript code.
  • When you need your Silverlight control to communicate with the Server side web form, use hidden server controls and trigger them with client side javascript code ( works in a similar way – holds hidden fields to postback data). To update the gridview I spoke about in the previous example, when a specific series of the graph is clicked, you could use a hidden LinkButton for each series of data and trigger it using javascript.
    <asp:LinkButton ID="itemLink" runat="server" CssClass="Hidden"
      CommandArgument="something to specify which link was clicked"


    <Polygon Name="Match the id of the hyperlik"
        MouseLeftButtonDown='javascript:seriesClick' ... />


    function seriesClick(sender, eventArgs)
     // args= ... prepare your event args
      __doPostBack(, args);

    Server Side Event Handler

    protected void invisbleLinks_Command(object source,
    CommandEventArgs e) { //do what ever you need }

  • Things are much easier, when you need to call a javascript method to update the silverlight control. All you need to do is use the scriptManager’ s register script methods, passing the script function you want to call.
        this, this.GetType(),
        "Javascript function you want to call after an ajax post back",

In ASP.NET, as you may already know, you can set most of the Page Directives at the web.config Pages section if you need these directives to apply to all pages contained in your Web application.

So setting EnableViewState to false, for example, in web.config’s Pages section means that none of your page will use ViewState to persist state for its controls. So “what happens if I have an exception, a page that needs viewstate” you might ask.

In most of the cases setting the corresponding directive’s value at the Page declaration normally overrides the global web.config one, but that’s not the case with EnableViewState. If this directive is set to the web.config file, then no matter what you type on the Page won’t change the globally set value.

If you have an exception then you’ll have to remove the global setting completely and specify the directive at each web form in your web application.

So now you’ll know what’s going on next time you’ll find yourself searching why on earth viewstate is disabled even though you’ve explicitly set EnableViewState=”true” at the Page directive.

When all Greek channels yesterday, were either re-running ancient Greek movies, having long boring political debates or playing some b-movie I was able to: (This is why TV is sentenced to death…)

LiveEarthIf you missed it, don’t worry you can still “answer the call” at