Blog - Microsoft .NET, ASP.NET, AJAX and more

Silverlight 3 ElementName DataBinding Problem

by Damien White 11/19/2009 10:27:09 AM

I’ve been using Silverlight 3 heavily for the past few months, and during that time have discovered many things to love and hate.  One problem I faced with Silverlight 3 (that I should have blogged about earlier) is something I think many developers may have faced.  In the application I’ve been working on, we’ve broken up our functionality into “partial views” (we’re using MVVM) by encapsulating logic into Silverlight UserControls.  Well with this approach, we ran into an interesting binding problem.

Let’s say you have a UserControl, and that UserControl exposes a DependencyProperty.  Then within the UserControls content, you try to bind a control to that Dependency Property.  Well there’s an interesting issue with that approach in Silverlight 3.  Let’s look at a very simple example and see where the problem exhibits itself.

In this example, we’ll be creating a totally useless application to illustrate the point.  We’ll have a Page (MainPage.xaml), and one UserControl (MyControl.xaml).  The UserControl will consist of a single string property called MyText and the goal is to get that property’s value to be displayed in a TextBlock (which is within the UserControl).  We’ll then add that UserControl to the page, and we’ll dynamically set MyText on the UserControl.  Simple setup, right?  What can go wrong? Well, let’s get started.

More...

Shout it kick it on DotNetKicks.com Bookmark and Share
Tags: ,
Categories: Silverlight
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Book Review – Manning The Art of Unit Testing

by Damien White 9/30/2009 3:57:11 PM

The Art of Unit TestingTo some, “unit testing” is a four letter word.  While it’s unfortunate, the feeling is justified by poor experiences, lack of knowledge, and so on.  Personally, I’ve had mixed experiences with unit tests.  I’m sure many of you have encountered similar situations.  After reading The Art of Unit Testing by Roy Osherove, I feel far more confident in not only understanding unit tests, but also the best practices for implementation.  If this book had only been written years ago, maybe all those poor unit testing experiences would have never happened. 

The fundamental thing that I think is most misunderstood about unit testing is simply not understanding what a unit test is.  In fact, Roy just recently posted an updated definition of how he would classify a unit test on his blog.  Of course a definition isn’t always enough, and in his book, Roy starts off by fully explaining all the aspects of what a unit test should be and the basic outline for how to succeed.  I would highly recommend that you visit his book’s webpage (http://manning.com/osherove/) and download the sample first chapter

This seriously may be the best book ever written on unit testing.  I understand that “the best” is a strong statement, but this book is really the perfect package.  Let’s look at what makes this such a winner… More...

Shout it kick it on DotNetKicks.com Bookmark and Share
Tags:
Categories: Review | C#
Actions: E-mail | Permalink | Comments (2) | Comment RSSRSS comment feed

Silverlight 3 NavigationCacheMode To The Rescue

by Damien White 9/22/2009 9:29:46 PM

Missing-Piece I’ve been lucky enough to work on a new project for a client involving Silverlight 3 and the Silverlight Virtual Earth CTP.  One reoccurring issue that keeps coming up is performance, and I’m always looking for ways to balance functionality with speed.  In the app we are loading up a Virtual Earth map and populating it with data (nothing new).  We have a fair amount of data being loaded for various functions and layers.  Users are able to show and hide layers as well as interact with the map’s basic functions (zoom, pan, etc).  Users can then navigate to other areas based on selections from the map page. 

Since we’re using SL3, we’re using the Navigation Framework to navigate between “pages.”  If you’re not familiar with the Navigation Framework, check out Martin Mihaylov’s article, or if you prefer videos, be sure to check out Tim Heuer’s video on the topic.  Now let’s move on to the problem, and a solution…

More...

Shout it kick it on DotNetKicks.com Bookmark and Share
Tags:
Categories: Silverlight
Actions: E-mail | Permalink | Comments (3) | Comment RSSRSS comment feed

ASP.NET 4.0 AJAX Issues

by Damien White 8/27/2009 8:14:58 PM

PuzzledMan I’ve been using ASP.NET AJAX 4.0 quite a bit lately in ASP.NET 3.5 applications.  I encountered two issues tonight, and I hope this post saves someone some grief.

The first problem has to do with referencing the ASP.NET AJAX 4.0 library within an ASP.NET 3.5 application, and the second was a surprising data binding issue using the DataView

If you are looking for more information on ASP.NET AJAX 4.0, be sure check out my other articles on the site.

Issue 1 – The ScriptManagerProxy and CompositeScripts

The first issue I encountered was a client side error when using the DataView on a content page in my ASP.NET 3.5 SP1 application.  This site utilizes master pages, so I’m using a WebForm, otherwise I probably would have just gone with a plain old HTML page.  Regardless, since this is an ASP.NET application and the ScriptManager is declared in the Master page, I added the ASP.NET 4.0 AJAX scripts to a ScriptManagerProxy (instead of the ScriptManager itself). The code for the ScriptManagerProxy looks very similar to that for the ScriptManger.

More...

Shout it kick it on DotNetKicks.com Bookmark and Share
Tags:
Categories: AJAX | ASP.NET
Actions: E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

ASP.NET AJAX 4.0 and the ScriptManager Control

by Damien White 6/1/2009 7:15:48 PM

Puzzle Pieces I have been using ASP.NET AJAX 4.0 quite a bit lately, as I’m sure most of you are aware from my recent posts.  In those posts, I used standard HTML script references to show that ASP.NET AJAX is not reliant upon ASP.NET.  I realize that many of you are in fact using ASP.NET, and today we will take a look at using the ScriptManager. 

First we’ll look at using the Preview 4 scripts within an ASP.NET 3.5 application (with the ScriptManager of course) as well as using client templates and ADO.NET Data Services with the ScriptManager in ASP.NET 4.0 (Beta 1).  After that, we’ll take a closer look at some of the new features of the ScriptManager in ASP.NET 4.0. 

Preview 4 and the ASP.NET 3.5 ScriptManager

In my posts on ASP.NET AJAX 4.0 so far, I used standard HTML script references (as stated earlier).  However, what if you wanted to incorporate the new ASP.NET AJAX 4.0 scripts with a ScriptManager.  I tried this in a recent ASP.NET 3.5 SP1 project, and ran into some issues getting it all to work out.  Thanks to this blog (and Bertrand LeRoy), I found the solution.

<asp:scriptmanager id="sm" runat="server">
<scripts>
<asp:scriptreference scriptmode="Inherit" name="MicrosoftAjax.js" path="~/scripts/MicrosoftAjax.js" />
<asp:scriptreference scriptmode="Inherit" path="~/scripts/MicrosoftAjaxAdoNet.js" />
<asp:scriptreference scriptmode="Inherit" path="~/scripts/MicrosoftAjaxTemplates.js" />
</scripts>
</asp:scriptmanager>

More...

Shout it kick it on DotNetKicks.com Bookmark and Share