<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Web.NET</title><link>http://blog.turlov.com/</link><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Webnet" /><description>It's all about using ASP.NET with AJAX, C# and Javascript in the most efficient way for building web applications for 2.0 era.</description><language>en</language><managingEditor>noreply@blogger.com (Alexander Turlov)</managingEditor><lastBuildDate>Wed, 30 May 2012 09:12:01 PDT</lastBuildDate><generator>Blogger http://www.blogger.com</generator><openSearch:totalResults xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">43</openSearch:totalResults><openSearch:startIndex xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">1</openSearch:startIndex><openSearch:itemsPerPage xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/">25</openSearch:itemsPerPage><feedburner:info uri="webnet" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><feedburner:emailServiceId>Webnet</feedburner:emailServiceId><feedburner:feedburnerHostname>http://feedburner.google.com</feedburner:feedburnerHostname><item><title>Fixing 'Bootmgr is missing'  problem on Windows 7</title><link>http://feedproxy.google.com/~r/Webnet/~3/Y7nlyPM8k0E/fixing-bootmgr-is-missing-problem-on.html</link><category>Windows 7</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 21 Feb 2012 11:21:35 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-9119168848580157276</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
The reason for this post is that it took me three hours on the weekend to fix this problem and based on the amount of search results the Google returns for that keywords I figured there are a lot of people facing such a problem. So my goal is to provide with a simple explanation and easy fix to save one's time and may be even prevent this problem from happening.&lt;br /&gt;
&lt;br /&gt;
Let's start first from understanding what exactly is the problem. Secondly we see how to fix it and lastly we discuss the scenarios that could cause such a problem.&lt;br /&gt;
&lt;h3&gt;The problem&lt;/h3&gt;
When one tries to boot up a computer with Windows 7 OS on it and instead sees a black screen with a message "Bootmgr is missing - Press CTRL+ALT+DEL to restart". (I guess it's obvious that restarting will not fix the problem)&lt;br/&gt;&lt;br/&gt;There is an important condition for the fix described in this article: the computer was booting before but after some changes this error occurred. If this is not the case than the solution might not be applicable but from another hand it would not hurt to read further.&lt;br /&gt;
&lt;br /&gt;
So what exactly is the problem? The answer is easy: it's right in the message. Windows is looking for a file with a name "bootmgr" and cannot find it. This is a hidden file of a size about 320Kb that should reside in the root of a boot partition on a hard drive where the Windows OS is installed. We will discuss the reasons why it's missing later but now since we know what the problem is how can it be fixed?
&lt;br /&gt;
&lt;h3&gt;The fix&lt;/h3&gt;
Copy the bootmgr file from the source to the root of the boot Windows partition on hard drive. An XCOPY command can be used with an /h switch that allows copying hidden and system files. For example:&lt;br /&gt;
&lt;code&gt;X:/&gt;xcopy bootmgr C:\ /h&lt;/code&gt;
&lt;br /&gt;
&lt;h4&gt;Where to find the bootmgr file?&lt;/h4&gt;
This is an important question. The answer depends on a particular computer's configuration but based on the problem statistics let's just mention the most probable locations to search for the file (don't forget it's hidden):
&lt;ul&gt;
&lt;li&gt;Root of another hard drive with Windows 7 on it&lt;/li&gt;
&lt;li&gt;Root of another partition on the same hard drive with Windows 7 on it&lt;/li&gt;
&lt;li&gt;Windows 7 installation DVD&lt;/li&gt;
&lt;/ul&gt;
Once you figure the location of the bootmgr file simply copy it over to a boot partition and restart the computer: it should be able to boot in windows successfully this time and you are done.
&lt;h3&gt;The possible causes of the problem&lt;/h3&gt;
In my case and based on the Internet search results that seems to be a very popular cause I have installed a second hard drive in the computer and then installed Windows 7 on a new hard drive. The key here is that Windows installer did not copy the bootmgr file on a new hard drive because it already existed on an old hard drive. The same problem would have happened if Windows was installed on a new partition on the same hard drive where another Windows installation present. These two reasons cover over 80% of the problem occurrences with some variations around different versions of Windows that existed at the moment of a new Windows installation and dual-boot related problem with the same outcome.&lt;br/&gt;&lt;br/&gt;Another set of reasons relate to hardware problems with hard drives and not covered in this post for an obvious reason that the only solution for that is to replace a hard drive and reinstall Windows.
&lt;h4&gt;Prevention&lt;/h4&gt;
Apparently the only proper way of installing Windows is first to hide a hard drive or a partition with another Windows installation and once a new Windows is installed make it visible again. Unfortunately to the best of my knowledge that is not mentioned in the installation instruction.
&lt;h4&gt;Advanced technical details&lt;/h4&gt;
For those who would like to dig a bit deeper I suggest to boot into a Windows Recovery environment (F8 for Windows boot advanced options), open a command line prompt and use a bcdedit utility to explore the BCD (boot configuration database) content to see where Windows looks for the bootmgr file.
&lt;h3&gt;Conclusion&lt;/h3&gt;
Once the cause of the problem is understood the fix is easy however the search for the cause has been significantly slowed down by an amount of misinformation that Google search returned.
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-9119168848580157276?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/Y7nlyPM8k0E" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-21T14:21:35.864-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2012/02/fixing-bootmgr-is-missing-problem-on.html</feedburner:origLink></item><item><title>Using Anonymous Types Outside of Local Context with Dynamic Keyword</title><link>http://feedproxy.google.com/~r/Webnet/~3/fFL_e3wqBDI/using-anonymous-types-outside-of-local.html</link><category>better coding</category><category>CodeProject</category><category>C#</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Sat, 05 Nov 2011 12:55:00 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-8584497426459086266</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/bb397696.aspx" target="_blanc"&gt;Anonymous types&lt;/a&gt; that have been introduced in C# with .NET 3.5 is a convenient and powerful feature and can be used to simplify and speed up development without sacrificing code quality or violating coding standards. Perhaps one most widely known application is to use anonymous types in a context of &lt;abbr title="Language Integrated Query"&gt;LINQ&lt;/abbr&gt; expressions since that is mentioned on MSDN in most of the anonymous types related examples. Such strong association between anonymous types and LINQ though being true creates a wrong impression of that LINQ is the only application for anonymous types an perhaps discourages many developers from discovering many other ways of utilizing anonymous types. For example, I could mention returning anonymous type object from a &lt;abbr title="JavaScript Object Notation"&gt;JSON&lt;/abbr&gt; enabled ASP.NET Web, WCF or MVC service method which is extremely beneficial due to anonymous types being very lightweight and readily JSON serializable. However that is a topic for another article.&lt;br /&gt;
&lt;br /&gt;
When considering their applicability anonymous types frequently declined to be used due to their local scope visibility that is usually considered an unbreakable obstacle. What that means is an anonymous type object can only be used inside a code scope where it was defined with the largest scope being a method scope. In other words an anonymous type object cannot be used as a strongly typed object outside of its scope of visibility since its type does not exist in an outer scope from the compiler point of view. For example, if an anonymous object returned from a method it can only be seen and used as a base C# &lt;i&gt;object&lt;/i&gt; type which makes it totally useless from a conventional point of view since its properties and their values are not accessible. Compiler will throw an error on any attempt to cast an anonymous type object to any other type. Based on the above the obvious conclusion would be to not continue down this road and consider the topic closed. That is however not true.&lt;br /&gt;
&lt;br /&gt;
With another powerful feature introduced in C# by .NET 4 called &lt;a href="http://msdn.microsoft.com/en-us/library/dd264741.aspx" target="_blanc"&gt;dynamic types&lt;/a&gt; anonymous types are given even more reasons to be used since they now can be used outside of their scope of visibility. Sounds fantastic? Let me show you how it's done.&lt;br /&gt;
&lt;br /&gt;
Let's consider a usual scenario when there is a long list of complex objects that is used as a data source and we need to select several objects from that list and display some of their properties. Old school approach would be to define a &lt;abbr title="Plain Old CLR Object"&gt;POCO&lt;/abbr&gt; type that consists of properties to display, iterate through the original list and build a new list of POCO objects populated from the data source properties and then bind that list of POCO objects to a visual control that displays the output. Nothing is wrong with that except that a new POCO type must be defined even if it's not going to be reused anywhere else. That requires additional coding and future maintenance if the content that should be displayed changes. With anonymous types we can avoid creating a POCO type by using an anonymous type instead and providing a list of anonymous objects as a data source for the visual control. That will work just fine as long as no additional data processing is required against the list of the anonymous objects. Often however it is required to perform some additional processing against a newly build data source which is now a list or anonymous objects and this is where the problem occurs: it is not possible to access properties of an anonymous object outside of a method where this object was created. Is it true though?&lt;br/&gt;
&lt;br /&gt;
A &lt;i&gt;dynamic&lt;/i&gt; keyword allows to overcome this problem as it instructs compiler to not perform a compile time type check and leave that to the run-time environment. As such we can write a C# code that operates with an anonymous object as it was a strongly typed object. See the code example below:&lt;br/&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
object[] GetList()
{
 // Elements is a long list of complex objects
 var result = new ArrayList();
 foreach (var element in Elements)
 {
  if (/*condition to select a single element */)
  {
   result.Add(new { P1 = elemet.Prop1, P2 = element.Prop2, P3 = element.Prop3 });
  }
 }
 return result.ToArray();
}

// Note: input parameter el is declared as dynamic
void ProcessElement(dynamic el)
{
 // Cool! For a dynamic type compiler allows accessing properties by names
 var p1 = el.P1;
 var p2 = el.P2;
 var p3 = el.P3;
 // Now we can do something that we need with an anonymous object!
}

void PerformLogic()
{
 var list = GetList();
 foreach (var element in list)
 {
  ProcessElement(element);
 }
 // do something else...
}
&lt;/script&gt;&lt;br/&gt;
I assume comments are not required for the example as it speaks for itself. Just try and use this cool technique in your next project and see how much time and headache you'll save.&lt;br/&gt;&lt;br/&gt;
Just to reiterate: &lt;i&gt;anonymous types&lt;/i&gt; is a powerful feature that helps create cleaner and better code however it has some limitations. Using a &lt;i&gt;dynamic&lt;/i&gt; keyword allows to overcome limitations of the &lt;i&gt;anonymous types&lt;/i&gt;.
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-8584497426459086266?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/fFL_e3wqBDI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-05T15:55:00.843-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2011/11/using-anonymous-types-outside-of-local.html</feedburner:origLink></item><item><title>Using jQuery to Consume ASP.NET MVC JSON Services</title><link>http://feedproxy.google.com/~r/Webnet/~3/DvfLW_iCTgE/using-jquery-to-consume-aspnet-mvc-json.html</link><category>JavaScript</category><category>CodeProject</category><category>ASP.NET MVC</category><category>jQuery</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 12 Jul 2011 20:32:01 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-1280199816569717622</guid><description>&lt;h4&gt;Introduction&lt;/h4&gt;Since the inception of ASP.NET Web Services have been an important part of any professional web developer's tool set. Starting .NET 3.5 Web Services became even more useful as it became possible to call Web Services asynchronously from a browser using JavaScript and ASP.NET AJAX.&lt;br /&gt;
&lt;br /&gt;
However for the last two years the alternative ASP.NET MVC framework has been drawing more and more attention from the development community due to its good implementation of the MVC design pattern and adherence to web standards and bleeding edge web technologies.&lt;br /&gt;
&lt;br /&gt;
For many experienced ASP.NET developers accustomed to Web Services especially accompanied with ASP.NET AJAX framework a natural question occurs: &lt;i&gt;how to implement similar approach with ASP.NET MVC framework and its natural JavaScript companion jQuery?&lt;/i&gt;&lt;br /&gt;
&lt;h4&gt;ASP.NET MVC JSON Services&lt;/h4&gt;First of all there is no concept of Web Services in ASP.NET MVC however it is very easy to implement its functional analog. Any Controller Action method that returns data rather than an HTML formatted page can be considered an analog of a Web Method and used correspondingly. From this point of view a set of Controller Action methods that return properly formatted JSON response I will call &lt;i&gt;MVC JSON Services&lt;/i&gt;. Below is a simple example:&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
public class JsonServicesController : Controller
{
  ...
  public JsonResult MyJsonMethod()
  {
      // ... acquire an instance of an object
      return Json(data);
  }
  ...
}
&lt;/script&gt;&lt;br /&gt;
The code above when properly implemented should return a JSON representation of the &lt;b&gt;data&lt;/b&gt; object and that is an illustration of how easy it is to implement an MVC JSON Service method.&lt;br /&gt;
&lt;h4&gt;Security&lt;/h4&gt;By default a JSON Service method will throw an exception when called by an HTTP GET request. This behavior is in accordance with the behavior of a regular ASP.NET Web Service method that also would not accept a GET request. This is also considered a best practice to call a JSON Service method only by HTTP POST request. In order to implement that an [HttpPost] attribute should be applied to a JSON Service method. If you would like to learn more about security considerations &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/04/04/json-hijacking-and-how-asp-net-ajax-1-0-mitigates-these-attacks.aspx" target="_new"&gt;read this post&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Another consideration is authentication/authorization. Similarly to any other Controller Action method an [Authorize] attribute applied to the JSON Service method controls that the method can only be called by an authenticated user with proper authorization (if required).&lt;br /&gt;
&lt;br /&gt;
Now the corrected JSON Service method will look like this:&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
public class JsonServicesController : Controller
{
  ...
  // uncomment below if authentication required
  //[Authorize]
  [HttpPost]
  public JsonResult MyJsonMethod()
  {
      // ... acquire an instance of an object
      return Json(data);
  }
  ...
}
&lt;/script&gt;&lt;br /&gt;
&lt;h4&gt;How to use jQuery to call an MVC JSON Service method&lt;/h4&gt;One of the most popular application for JSON Services is to call them from JavaScript asynchronously and then use returned data to update the HTML content. With regular ASP.NET and ASP.NET AJAX such an exercise would be easy to accomplish as all the necessary JavaScript code is automatically generated and referenced on the page. That convenience however comes with a price of bigger payload and longer loading time as many additional scripts must be referenced on a page.&lt;br /&gt;
&lt;br /&gt;
In ASP.NET MVC natural JavaScript environment is jQuery library that has everything we need in order to accomplish our task. See the code example below:&lt;br /&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
  function getMyObject(onSuccess) {
    $.ajax({
       type: "POST",
       contentType: "application/json;charset=utf-8",
       url: "/JsonService/MyJsonMethod",
       data: "{}",
       dataType: "json",
       success: onSuccess
    });
  }
&lt;/script&gt;&lt;br /&gt;
We use &lt;a href="http://api.jquery.com/jQuery.ajax/" target="_new"&gt;a jQuery.ajax method&lt;/a&gt; to make an asynchronous POST request to our JSON Service method. Notice &lt;b&gt;contentType&lt;/b&gt; and &lt;b&gt;dataType&lt;/b&gt; properties that are responsible for identifying that we are requesting and expecting back JSON-formatted data. The &lt;b&gt;url&lt;/b&gt; property defines the URL of our JSON Service method constructed based on standard ASP.NET MVC Routing rules. The value of the &lt;b&gt;success&lt;/b&gt; parameter is a callback function name that will be called when the request completes successfully.&lt;br /&gt;
&lt;h4&gt;Input parameters&lt;/h4&gt;Rarely the Service methods are called without parameters. In case of one or two simple parameters we can rely on ASP.NET MVC Routing automatic parameters mapping feature that will automatically extract a parameter from the URL and then pass it to a Service method. Look at the example.&lt;br /&gt;
&lt;br /&gt;
Let's assume we would like to call a JSON Service method with a single parameter "id" that is used to acquire our data object on the server side. First we'll have a corresponding routing rule defined in the global.asax.cs file:&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
  public static void RegisterRoutes(RouteCollection routes)
  {
     ...
     routes.MapRoute(
          "JsonService",
          "{controller}/{action}/{id}",
          new { controller = "JsonServices", action = "GetData", id = UrlParameter.Optional } 
     );
     ...
  }
&lt;/script&gt;&lt;br /&gt;
Next we'll have a JSON Service method with a parameter:&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
public class JsonServicesController : Controller
{
  ...
  // uncomment below if authentication required
  //[Authorize]
  [HttpPost]
  public JsonResult MyJsonMethod(string id)
  {
      // ... acquire an instance of an object
      return Json(data);
  }
  ...
}
&lt;/script&gt;&lt;br /&gt;
When we call our JSON Service method using a URL like "JsonServices/MyJsonMethod/123456" the method will receive a string value "123456" as an &lt;b&gt;id&lt;/b&gt; parameter automatically.&lt;br /&gt;
&lt;br /&gt;
That was simple. Now what if we need to pass a complex object as a parameter and we cannot use URL? In this case we just pass a JSON literal as a string representing our complex parameter using a data property in the jQuery.ajax method:&lt;br /&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
  function getMyObject(onSuccess) {
    $.ajax({
       type: "POST",
       contentType: "application/json;charset=utf-8",
       url: "/JsonService/MyJsonMethod",
       data: '{"id":"123456", "title":"object title"}',
       dataType: "json",
       success: onSuccess
    });
  }
&lt;/script&gt;&lt;br /&gt;
Now we need to modify our JSON Service method in order to receive the parameter correctly.&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
public class JsonServicesController : Controller
{
  ...
  // uncomment below if authentication required
  //[Authorize]
  [HttpPost]
  public JsonResult MyJsonMethod(MyObject param)
  {
      // ... acquire an instance of an object
      return Json(data);
  }
  ...
}
&lt;/script&gt;&lt;br /&gt;
We need to define a MyObject class as the following:&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
  [Serializable]
  public class MyObject {
      public string Id { get; set; }
      public string Title { get; set; }
  }
&lt;/script&gt;&lt;br /&gt;
Notice that the class is marked with a [Serializable] attribute and names of the public properties match exactly the ones we used in a JSON parameter string in the jQuery.ajax function call. This is just enough for the ASP.NET MVC framework to do all the work behind the scene and provide our JSON Service method with the correct parameter value. It's easy to see a similarity between this asynchronous AJAX call and a regular form POST request with the only difference that a parameter on the client side is provided as a JSON literal string. &lt;br /&gt;
&lt;h4&gt;Consuming returned data&lt;/h4&gt;Our final goal is to receive a JSON-formatted piece of data that we'll be able to consume by JavaScript and we hope to minimize our efforts by fully exploiting abilities of the ASP.NET MVC framework and jQuery library. So far we've managed to make a request to a server-side JSON Service method and the next step is to consume the returned data. We have provided the onSuccess JavaScript function as a callback to the jQuery.ajax method and we should use it for all the data processing we want.&lt;br /&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
  function onSuccess(data) {
    //example of a simple data processing
    var message = data.ResultMessage;
    $("#resultMessage").html(message);
  }
&lt;/script&gt;&lt;br /&gt;
When the AJAX request completes the &lt;b&gt;onSuccess&lt;/b&gt; function is called and receives a parameter &lt;b&gt;data&lt;/b&gt; that is our expected result. &lt;b&gt;data&lt;/b&gt; is already a regular JavaScript object that has been deserialized from a JSON string and we can use as intended. It fully corresponds to a server-side &lt;b&gt;data&lt;/b&gt; object that we have returned from a JSON Service method. Notice that as opposed to a regular Web Service call with ASP.NET AJAX the returned object is not wrapped in a "d" property so there is no need for additional processing.&lt;br /&gt;
&lt;h4&gt;A word about DateTime&lt;/h4&gt;If a returned object contains a property of a DateTime type the MVC framework returns it in a specific form that requires some preliminary processing on the client side before can be consumed. A simple function below converts a value returned by the MVC framework into a standard JavaScript Date object:&lt;br /&gt;
&lt;script class="brush: javascript" type="syntaxhighlighter"&gt;
  function toDate(dateValue) {
      return eval('new' + dateValue.replace(/\//g, ' '));
  }
&lt;/script&gt;&lt;br /&gt;
Please &lt;a href="http://weblogs.asp.net/bleroy/archive/2008/01/18/dates-and-json.aspx" target="_new"&gt;read this post&lt;/a&gt; and do some Internet search to better understand the mechanics of DateTime value format transformation when returned in a JSON-formatted message.&lt;br /&gt;
&lt;h4&gt;Conclusion&lt;/h4&gt;In this article we have learned how to implement a JSON Services using ASP.NET MVC framework and how to call JSON Services methods asynchronously from JavaScript using jQuery library.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-1280199816569717622?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/DvfLW_iCTgE" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-12T23:32:01.438-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.turlov.com/2011/07/using-jquery-to-consume-aspnet-mvc-json.html</feedburner:origLink></item><item><title>Fix for Bing Maps not working in Firefox 4+</title><link>http://feedproxy.google.com/~r/Webnet/~3/rEPwr3_c4Fw/fix-for-bing-maps-not-working-in.html</link><category>JavaScript</category><category>VirtualEarth</category><category>AJAX</category><category>ASP.NET</category><category>CodeProject</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 12 Jul 2011 12:26:29 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-3227177385220872923</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;UPDATE&lt;/b&gt;&lt;br /&gt;
&lt;i&gt;Apparently that problem exists for Firefox 5 also and perhaps will apply for the future versions too. So the solution below should be considered a best practice for using Bing Maps 6.x with Firefox 4+.&lt;/i&gt;&lt;br /&gt;
&lt;br /&gt;
Recently I've upgraded from Firefox 3.6 to Firefox 4 and while doing regression testing I've notice that apparently Bing Maps has some issues in Firefox 4. In particular I saw a JavaScript error that said "p_elSource.attachEvent is not a function":&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-dpiRejt83gY/Tb3mQWW4IXI/AAAAAAAAANI/TWj3Cdj_hq8/s1600/BingErrorFF4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="123" src="http://1.bp.blogspot.com/-dpiRejt83gY/Tb3mQWW4IXI/AAAAAAAAANI/TWj3Cdj_hq8/s400/BingErrorFF4.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
The problem at this point looks like this:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;the error happens in Bing's JavaScript itself; and &lt;/li&gt;
&lt;li&gt;it only happens in Firefox 4 browser. Other browsers like IE 8 &amp;amp; 9, Chrome, Safari, Opera and Firefox 3.6 don't produce that problem.&lt;/li&gt;
&lt;/ol&gt;Since the page where I saw an error belonged to a web application I've been working on I had to fix the problem. Initial search on the Internet did not bring up anything useful except that a few other people also stepped on this problem. I tried Bing Maps interactive SDK and it worked all right. That told me the Bing Maps script itself does work but it clearly depends on some other condition that does not necessarily happen on other pages like mine.&lt;br /&gt;
&lt;br /&gt;
What's that condition? I looked at the difference between Firefox browser and the other browsers. When in Firefox Bing Maps dynamically loads another JavaScript file &lt;b&gt;atlascompat.js&lt;/b&gt;. Apparently that file is required since it contains a definition for the &lt;b&gt;attachEvent&lt;/b&gt; function that caused an error and must be loaded first before the main Bing Maps script. So that's the condition I've been looking for! Now the picture got clearer:&lt;br /&gt;
&lt;ol style="text-align: left;"&gt;&lt;li&gt;the error happens in Bing's JavaScript itself; and &lt;/li&gt;
&lt;li&gt;it only happens in Firefox 4 browser. Other browsers like IE 8  &amp;amp; 9, Chrome, Safari, Opera and Firefox 3.6 don't produce that  problem;&lt;/li&gt;
&lt;li&gt;it happens when the atlascompat.js is not present on a page at the moment when the main Bing Maps script is being loaded. &lt;/li&gt;
&lt;/ol&gt;Now why the error is happening on my page and not on the Bing Maps SDK page? Apparently the conditions #3 is not satisfied since my page contains a whole bunch of other scripts and the &lt;b&gt;atlascompat.js&lt;/b&gt; did not load before the main Bing Maps script due to internal differences that have been introduced in Firefox 4. Now I have a complete picture of the problem and can come up with a solution for it.&lt;br /&gt;
&lt;br /&gt;
The solution is simple: since the Bing Maps itself cannot load the &lt;b&gt;atlascompat.js&lt;/b&gt; reliably I need to help it and just add a reference to the &lt;b&gt;atlascompat.js&lt;/b&gt; script on my page before a reference to the main Bing Maps script. This can be easily accomplished with a few line of code like below:&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: csharp" type="syntaxhighlighter"&gt;
    if ((Page.Request.Browser.Browser.IndexOf("Firefox") &gt;= 0) &amp;&amp; (Page.Request.Browser.MajorVersion &gt;= 4))
    {
       // add script reference on a page
       // use technique that is suitable for your application
    }
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Notice that the browser version is more or equal 4 to cover the future versions of Firefox too (for version 5 this solution is confirmed). In my case I've added the code above into a &lt;b&gt;GetScriptReferences&lt;/b&gt; method of an &lt;b&gt;IScriptControl&lt;/b&gt; that was responsible for rendering the Bing Maps on a page.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-3227177385220872923?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/rEPwr3_c4Fw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-07-12T15:26:29.677-04:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-dpiRejt83gY/Tb3mQWW4IXI/AAAAAAAAANI/TWj3Cdj_hq8/s72-c/BingErrorFF4.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.turlov.com/2011/05/fix-for-bing-maps-not-working-in.html</feedburner:origLink></item><item><title>.NET Reflector is becoming a paid-for product</title><link>http://feedproxy.google.com/~r/Webnet/~3/JcOzteEQC6k/net-reflector-is-becoming-paid-for.html</link><category>Open source</category><category>CodeProject</category><category>Community</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Sat, 05 Nov 2011 13:04:29 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-7867609741242793002</guid><description>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
As you may already have learned the &lt;a href="http://www.red-gate.com/products/dotnet-development/reflector/"&gt;famous .NET Reflector&lt;/a&gt; created by &lt;a href="http://blog.lutzroeder.com/"&gt;Lutz Roeder&lt;/a&gt; almost a decade ago that was always free to use is &lt;a href="http://www.red-gate.com/products/dotnet-development/reflector/announcement"&gt;becoming a paid-for product thanks to Red Gate Software&lt;/a&gt;. The decision is confirming the worst suspicions many had when first heard about Lutz's agreement with the Red Gate and has already created a massive controversy in development communities.&lt;br /&gt;
&lt;br /&gt;
For those who do not remember the .NET Reflector was born in the beginning of 2000s and has quickly become one of the must-have tool for every serious professional .NET developer. A large users community has quickly formed around the tool and &lt;a href="http://reflectoraddins.codeplex.com/"&gt;many great add-ons&lt;/a&gt; have been written by inspired developers. Reflector has influenced great many developers' careers and earned community recognition. Scott Hanselman included the program in his &lt;a href="http://www.hanselman.com/blog/ScottHanselmans2007UltimateDeveloperAndPowerUsersToolListForWindows.aspx"&gt;"Ultimate Developer Tool List"&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
The Reflector's success was growing for over half a decade when out of a sudden the original author of .NET Reflector &lt;a href="http://blog.lutzroeder.com/2008/08/future-of-net-reflector.html"&gt;announced about his decision to stop developing the product and give it over to Red Gate Software&lt;/a&gt; in August 2008. One part of the agreement was that &lt;br /&gt;
&lt;blockquote&gt;
...Red Gate will continue to provide the free community version... [of .NET Reflector]&lt;/blockquote&gt;
&lt;a href="http://www.simple-talk.com/opinion/opinion-pieces/the-future-of-reflector-/"&gt;confirmed by James Moore of Red Gate Software&lt;/a&gt; but many had skepticism about that part of the agreement from the very beginning.&lt;br /&gt;
&lt;br /&gt;
During the period of Red Gate's ownership there were not many real improvements to the Reflector except for the annoying built-in "time-bomb" feature forcing one to upgrade to the newer version of the product even though the installed version worked perfectly. Some time ago a paid-for "Pro" version was announced with an obvious reason to raise some money for the owner but based on the &lt;a href="http://www.red-gate.com/products/dotnet-development/reflector/announcement"&gt;Red Gate's plea&lt;/a&gt; was not successful among developers. One of the suggested explanations for that is that paid-for functionality was not really of any interest (more creativity, please, Red Gate) for professionals and beside there were already free add-ons doing similar things.&lt;br /&gt;
&lt;br /&gt;
So now Red Gate wants to charge $35 for "a perpetual license, with no time bomb or forced updates" for the version 7 that will come out in early March and promises some &lt;a href="http://www.simple-talk.com/community/blogs/clivet/archive/2011/02/01/99118.aspx"&gt;new features in V7&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
Red Gate claims that they need money to "keep .NET Reflector up-to-date and relevant" and cannot do that "without revenue coming in". That may be true for the Red Gate Software but there is a proven recipe for that: how about make the product open source, put it on Code Plex or any other similar location and let the community take care of its relevancy? To make it even more interesting let's make it a challenge: you, Red Gate, charge for your new shiny V7 but give away the previous version to the open source community and let's see which version survives in a few years. I personally have no doubts on the results.&lt;br /&gt;
&lt;br /&gt;
There is a discussion going on about the Reflector's future on &lt;a href="http://www.red-gate.com/MessageBoard/viewtopic.php?t=12772"&gt;Red Gate's user forum&lt;/a&gt;. However if you are a professional developer that uses and loves Lutz Roeder's Reflector I encourage you to share your opinion and vote for the Reflector's future right here in my blog on the right side or answer polls on LinkedIn &lt;a href="http://linkd.in/fMMPY5"&gt;here&lt;/a&gt; and &lt;a href="http://linkd.in/gR46d9"&gt;here&lt;/a&gt;. Please share the poll with your friends and colleagues.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;b&gt;UPDATE&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Interesting list of open-source alternatives to Reflector on Stack Overflow: &lt;a href="http://stackoverflow.com/questions/2425973/open-source-alternatives-to-reflector"&gt;http://stackoverflow.com/questions/2425973/open-source-alternatives-to-reflector&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To my taste the closest to .NET Reflector user experience is provided by the &lt;a href="http://wiki.sharpdevelop.net/ILSpy.ashx"&gt;ILSpy&lt;/a&gt;. I am going to try and compare it with the Reflector.&lt;br /&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;b&gt;Another UPDATE of May 1, 2011&lt;/b&gt;&lt;br /&gt;
Apparently free Reflector's lifespan is going to end on May 30, 2011. Today I've started my free copy and saw this alert:&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://4.bp.blogspot.com/-A1yPoYSWfoQ/Tb3ikkoim4I/AAAAAAAAANA/BzRihYT_-pE/s1600/ReflectorAlert.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="137" src="http://4.bp.blogspot.com/-A1yPoYSWfoQ/Tb3ikkoim4I/AAAAAAAAANA/BzRihYT_-pE/s320/ReflectorAlert.png" width="320" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;b&gt;UPDATE of May 31, 2011&lt;/b&gt;&lt;br /&gt;
Free version of Reflector is finally dead. Now those who does not want to switch to a paid version has to consider alternatives. A couple of new alternatives include:&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;JustDecompile&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
Telerik has recently released a beta version of their new JustDecompile, designed to enable easy .NET assembly browsing and decompiling. While Telerik is not know for free software, this product is featured as being free. According to Telerik, "Unlike Open Source alternatives, Telerik JustDecompile benefits from a dedicated development team, which is focused on continuously improving the product in line with your feedback. Telerik is recognized as one of the leading providers of .NET development tools and JustDecompile will benefit from our years of experience in the field."&lt;br /&gt;
&lt;br /&gt;
&lt;em&gt;dotPeek&lt;/em&gt;&lt;br /&gt;
&lt;br /&gt;
JetBrains, an author of an extremely popular ReSharper Visual Studio add-in, has recently released a beta version of the dotPeek which is another new and free .NET decompiler with search features from JetBrains. dotPeek has gone public for the first time on Wednesday, May 11, as JetBrains opened an Early Access Program (EAP) that implied regular publishing of pre-release builds. According to JetBrains they are going to keep the product free.&lt;br/&gt;
&lt;br /&gt;
&lt;hr /&gt;
&lt;b&gt;Final Thought&lt;/b&gt;&lt;br /&gt;&lt;br/&gt;
JetBrain's &lt;em&gt;dotPeek&lt;/em&gt; has become my tool of choice for the time being. It's functional, free and being updated frequently. For those who also uses JetBrain's ReSharper starting version 6 the &lt;em&gt;dotPeek&lt;/em&gt; functionality is built-in and available through the &lt;em&gt;Navigate/To Decompiled Source&lt;/em&gt; menu.
&lt;br /&gt;&lt;br/&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-7867609741242793002?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/JcOzteEQC6k" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-05T16:04:29.714-04:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://4.bp.blogspot.com/-A1yPoYSWfoQ/Tb3ikkoim4I/AAAAAAAAANA/BzRihYT_-pE/s72-c/ReflectorAlert.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.turlov.com/2011/02/net-reflector-is-becoming-paid-for.html</feedburner:origLink></item><item><title>Set up local SMTP for your .NET development environment on Windows 7</title><link>http://feedproxy.google.com/~r/Webnet/~3/o6ujfu3hYhM/set-up-local-smtp-for-your-net.html</link><category>ASP.NET</category><category>Windows 7</category><category>CodeProject</category><category>IIS 7</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 28 Dec 2010 14:32:00 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-1988165567882945131</guid><description>If you are developing a .NET application that sends emails than you need a way to do that without being constantly connected to the Internet. On Windows 7 with IIS 7 installed you can easily configure a local SMTP service that will intercept all the SMTP sessions initiated in your code and successfully emulate sending the outbound email by saving it as a text file in a folder on your local hard drive. This is extremely convenient and allows you to keep working on your code without interruption even when you are not connected to the Internet.&lt;br /&gt;
&lt;br /&gt;
To achieve that just add a few lines in your application's .config file (could be web.config or app.config). Here is an example of such a configuration:&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&lt;system.net&gt;
    &lt;mailsettings&gt;
      &lt;smtp deliverymethod="SpecifiedPickupDirectory"&gt;
        &lt;specifiedpickupdirectory pickupdirectorylocation="c:\smtp" /&gt;
      &lt;/smtp&gt;
    &lt;/mailsettings&gt;
  &lt;/system.net&gt;
&lt;/pre&gt;&lt;br /&gt;
After adding such a configuration every time your application sends an e-mail using a .NET framework built-in &lt;i&gt;SmtpClient.Send&lt;/i&gt; method a new file with the .eml extension will appear in the configured folder.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;a href="http://3.bp.blogspot.com/_wYfdNSEIRks/TRpeJPgqy-I/AAAAAAAAALs/wpZ-2Ub-S4w/s1600/SmtpFolder.jpg" imageanchor="1" style="margin-left:1em; margin-right:1em"&gt;&lt;img border="0" height="138" width="320" src="http://3.bp.blogspot.com/_wYfdNSEIRks/TRpeJPgqy-I/AAAAAAAAALs/wpZ-2Ub-S4w/s320/SmtpFolder.jpg" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;br /&gt;
You can open a file with any text editor like Notepad++ for example or you can use this &lt;a href="http://www.nucleustechnologies.com/eml-viewer.html" target="_blanc"&gt;free EML Viewer&lt;/a&gt; to improve viewing experience.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-1988165567882945131?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/o6ujfu3hYhM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T17:32:00.062-05:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_wYfdNSEIRks/TRpeJPgqy-I/AAAAAAAAALs/wpZ-2Ub-S4w/s72-c/SmtpFolder.jpg" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2010/12/set-up-local-smtp-for-your-net.html</feedburner:origLink></item><item><title>Re: Can architecture emerge from continuous refactoring?</title><link>http://feedproxy.google.com/~r/Webnet/~3/QguZ-d892vk/re-can-architecture-emerge-from.html</link><category>architecture</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 14 Jul 2010 07:53:54 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-4100562678039625257</guid><description>Recently I've been asked this question "Can architecture emerge from continuous refactoring?" and since this topic is very close to what I do professionally I wanted to share my thoughts about it.&lt;br /&gt;
&lt;h4&gt;What is software architecture?&lt;/h4&gt;I see software architecture as a parallel to a traditional architecture: it consists of knowledge about everything that is required to build a successful software product as in to successfully construct a building. In a context of a particular project architecture eventually results in a team vision and a set of documents that guide the team towards the successful completion of a project and achieving the goal. From this point of view it is obvious that if the goal itself or any of its dependencies and prerequisite are not envisioned and well defined then a team simply will not know where to go and never reach the point of success.&lt;br /&gt;
&lt;h4&gt;Can software architecture emerge successfully from continuous small refactoring?&lt;/h4&gt;Often there is some legacy software in place and there is not enough time to redo the whole project from scratch so the only way is to apply small refactoring steps in order to make software better from the architecture standpoint.&lt;br /&gt;
&lt;br /&gt;
Hence software architecture can and should emerge successfully from continuous small refactoring. For me this is not a theory but a proven fact since that is what most of my job as a Software architect consists of: I am orchestrating my development team to apply continuous changes and refactoring to the code base in order to shape the architecture into the right direction.&lt;br /&gt;
&lt;h4&gt;Factors of success and failure of a re-architecture project&lt;/h4&gt;The main reason for success is for a team to be persistent and consistent on the way and for an architect to have a complete vision, fully understand the final state of the re-architecture process and the way of the architecture transformations.&lt;br /&gt;
&lt;br /&gt;
Opposite to the above when an architecture transformation is not a priority target and a team is not given enough time to work on the necessary changes then the new architecture will not emerge. It's not a "rocket science" and it's exactly the same process of achieving a goal as in any other human activity. &lt;br /&gt;
&lt;br /&gt;
Some other reasons of re-architecture failure could be lack of the architectural vision, poor management, lack of architecture transformation understanding but I don't consider those to be the primary reasons bur rather the missing prerequisites for a re-architecture project. &lt;br /&gt;
&lt;h4&gt;Lessons learned on the way&lt;/h4&gt;Even though it's somewhat useful to learn from mistakes but I'd rather learn from successful implementations since what you can learn is a way to actually achieve the success.&lt;br /&gt;
&lt;h4&gt;Re-architecture methodologies&lt;/h4&gt;Some people are convinced that using a right tool will guarantee the success and therefore focus on comparing and selecting the "best of the best" methodology. Lately the "agile" word became very popular in regards to that.&lt;br /&gt;
&lt;br /&gt;
From my experience any agile method is just a tool that may or may not help depending on a use case. Agile for me in this context is only a synonym of "continuous, persistent and consistent" way of moving towards a project's target. Whatever method is embraced by a team will work for me as long as it allows a successful completion of a project.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-4100562678039625257?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/QguZ-d892vk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-07-14T10:53:54.443-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2010/07/re-can-architecture-emerge-from.html</feedburner:origLink></item><item><title>How to set programmatically a value of a watermarked TextBox via JavaScript - Update</title><link>http://feedproxy.google.com/~r/Webnet/~3/Oh61LJ0wWdA/how-to-set-programmatically-value-of.html</link><category>JavaScript</category><category>ASP.NET</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Sat, 08 May 2010 14:57:33 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-5610694219862085461</guid><description>Some time ago I've published an article &lt;a href="http://blog.turlov.com/2009/06/how-to-programmatically-set-value-of.html"&gt;How to set programmatically a value of a watermarked TextBox via JavaScript&lt;/a&gt; about some specifics of working with a text input box decorated with a TextboxWatermark Ajax Extender control from the Ajax Control Toolkit library. The technique described in the article has proven useful for a number of developers so when the &lt;a href="http://ajaxcontroltoolkit.codeplex.com/releases/view/43475"&gt;new release of the Ajax Control Toolkit&lt;/a&gt; has recently been announced I've decided to update the article to cover some of the braking changes in Ajax Control Toolkit components.&lt;h3&gt;Ajax Control Toolkit changes&lt;/h3&gt;One of the most significant changes in the recent Ajax Control Toolkit release that affected everything is renaming namespaces and control names. Most of the JavaScript classes in the ACT has been moved into &lt;b&gt;Sys.Extended.UI&lt;/b&gt; and some of them renamed.&lt;br /&gt;&lt;br /&gt;Correspondingly the &lt;b&gt;AjaxControlToolkitTextboxWrapper&lt;/b&gt; class that is crucial for the technique described in this article is now called &lt;b&gt;Sys.Extended.UI.TextBoxWrapper&lt;/b&gt; and this is a breaking change. Most if its methods haven't been renamed and this is a good news however the new way of using the wrapper has been introduced.&lt;br /&gt;&lt;br /&gt;Below are the code examples demonstrating how to write the code correctly with the new version of the ACT.&lt;br /&gt;&lt;br /&gt;First we need to acquire an instance of the &lt;b&gt;Sys.Extended.UI.TextBoxWrapper&lt;/b&gt; class for our textbox control and this is the newly introduced technique compared to the previous version of the ACT:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;// get the instance of a textbox element&lt;br /&gt;var textBox = $get(textBoxId);&lt;br /&gt;// use the get_Wrapper static method of the TextBoxWrapper class to get the instance of the wrapper for the textbox&lt;br /&gt;var wrapper = Sys.Extended.UI.TextBoxWrapper.get_Wrapper(textBox);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;In the code above first I assume that the ACT is present so I don't have to check that &lt;b&gt;Sys.Extended.UI&lt;/b&gt; namespace is defined. Secondly the code above is safe even if the textbox is not watermarked: the &lt;b&gt;get_Wrapper&lt;/b&gt; static method will always return the instance of the TextBoxWrapper; the new instance will be created if the textbox is not watermarked.&lt;br /&gt;&lt;br /&gt;Now we can set or get a value of the textbox using the instance of the TextBoxWrapper:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;// get the textbox value&lt;br /&gt;var oldValue = wrapper.get_Value();&lt;br /&gt;// set the textbox value&lt;br /&gt;wrapper.set_Value(newVlaue);&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;In a nutshell there are two major changes introduced in the new ACT release that affect the coding technique described here: the name of the textbox wrapper class has been changed; and now it's not required to check whether the textbox is watermarked to use the technique above.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-5610694219862085461?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/Oh61LJ0wWdA" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-08T17:57:33.008-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://blog.turlov.com/2010/05/how-to-set-programmatically-value-of.html</feedburner:origLink></item><item><title>Leveraging Visual Studio JavaScript IntelliSense. Part 1</title><link>http://feedproxy.google.com/~r/Webnet/~3/C1fixOV7BmM/leveraging-visual-studio-javascript.html</link><category>JavaScript</category><category>AJAX</category><category>ASP.NET</category><category>CodeProject</category><category>Visual Studio</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Mon, 10 May 2010 07:44:08 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-2667737574768082100</guid><description>One of the most useful features of the Visual Studio 2008 and Visual Studio 2010 is JavaScript IntelliSense that allows developers write JavaScript code faster, with fewer errors and reduce learning time of some JavaScript frameworks. Many developers already enjoy its power when code JavaScript with Microsoft ASP.NET Ajax framework and jQuery. However many developers are still not familiar with that tool and even less developers realize that it can also be used with their own code.&lt;br /&gt;&lt;br /&gt;As convenient and powerful the JavaScript IntelliSense is as it is not intuitive to get started with mainly because of its lack of well-organized documentation and non-intuitive error diagnostics. Another obstacle is that it does not support its own XML code comments that makes it hard to use to the full extent without learning and memorizing first.&lt;br /&gt;&lt;br /&gt;This article aims to provide with a quick reference of the most useful features of the JavaScript IntelliSense to help make it an every-day tool for the JavaScript developers. &lt;br /&gt;&lt;br /&gt;In short words JavaScript IntelliSense provides with two main features:&lt;ol&gt;&lt;li&gt;It enables documentation and syntax support while coding for the core JavaScript elements and third-party JavaScript libraries;&lt;/li&gt;&lt;li&gt;It allows adding documentation and syntax support to the code being developed so other developers can use it.&lt;/li&gt;&lt;/ol&gt;In this post I cover the first feature.&lt;br /&gt;&lt;h3&gt;Enable JavaScript IntelliSense for third party JavaScript libraries&lt;/h3&gt;The IntelliSense support for the core JavaScript syntax is enabled by default. In order to enable IntelliSense for third party code one needs to satisfy the following requirements:&lt;ol&gt;&lt;li&gt;Reference a third party JavaScript file in your code, and&lt;/li&gt;&lt;li&gt;Make sure the third party JavaScript includes Visual Studio XML code comments&lt;/li&gt;&lt;/ol&gt;The second requirement is in fact optional because JavaScript IntelliSense will work even without XML comments but will provide with less information so it actually pays off checking out before choosing a third-party JavaScript library whether it has a VS IntelliSense support. Many of the most popular JavaScript libraries such as &lt;a href="http://www.asp.net/ajax/"&gt;ASP.NET Ajax&lt;/a&gt;, &lt;a href="http://ajax.microsoft.com/ajax/jQuery/jquery-1.3.2-vsdoc.js"&gt;jQuery&lt;/a&gt;, &lt;a href="http://vejs.codeplex.com/"&gt;Bing Maps&lt;/a&gt;, etc. do support VS IntelliSense.&lt;br /&gt;&lt;h4&gt;Referencing another JavaScript library in your JavaScript code&lt;/h4&gt;Simply use a &lt;b&gt;reference&lt;/b&gt; directive in your JavaScript code. There are a few flavors of that directive depending on the location of a third party JavaScript code. A &lt;b&gt;reference&lt;/b&gt; directive supports file-based, assembly-based, service-based, or a page-based script references. Below are the examples illustrating those scenarios:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush: javascript"&gt;&lt;br /&gt;// Reference a file-based JavaScript&lt;br /&gt;/// &lt;reference path="file-path-to/script-name.js" /&gt;&lt;br /&gt;&lt;br /&gt;// Reference a service-based JavaScript&lt;br /&gt;/// &lt;reference path="url-path-to/wcf-service.svc" /&gt;&lt;br /&gt;/// &lt;reference path="url-path-to/asmx-service.asmx" /&gt;&lt;br /&gt;&lt;br /&gt;// Reference a web page-based JavaScript&lt;br /&gt;/// &lt;reference path="url-path-to/page-name.aspx" /&gt;&lt;br /&gt;&lt;br /&gt;// Reference an embedded resource JavaScript&lt;br /&gt;/// &lt;reference name="resource-name" assembly="assembly-name" /&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;A &lt;b&gt;-path-to&lt;/b&gt; portion above can be both a file path to a local or network location or a web URL to both intranet and Internet resources. In the latter case keep in mind that the Internet resource will be accessed every time Visual Studio opens a JavaScript file with a reference so it is better to cache it locally which is also much safer. In case of a service-based reference the actual URL Visual Studio has to access will be &lt;i&gt;'service-url/jsdebug'&lt;/i&gt; or &lt;i&gt;'service-url/js'&lt;/i&gt; based on the solution configuration therefore make sure that the project a service belongs to compiles without errors.&lt;br /&gt;&lt;br /&gt;It is not necessary to reference an original JavaScript code itself (for example if it's hosted somewhere outside of your development environment) if there is a &lt;b&gt;VSDOC&lt;/b&gt; file provided as it is with jQuery or Bing Maps libraries for example.&lt;br /&gt;&lt;br /&gt;A VSDOC file is a JavaScript file that only includes objects definitions and functions signatures with XML comments without actual code and is a preferred way to add extensive documentation to a JavaScript library without modifying the original JavaScript code. In case there are no XML comments in the code nor VSDOC file is available simply reference an original JavaScript file and Visual Studio will parse it and provide you with the best possible IntelliSense help. If you use Microsoft ASP.NET Ajax framework add the following reference to the top of your JavaScript code:&lt;br /&gt;&lt;br /&gt;&lt;script type="syntaxhighlighter" class="brush: javascript"&gt;&lt;br /&gt;// Reference Microsoft ASP.NET Ajax framework&lt;br /&gt;/// &lt;reference name="MicrosoftAjax.js" /&gt;&lt;br /&gt;&lt;/script&gt;&lt;br /&gt;You may have noticed that this is a reference to an embedded resource but without assembly name. Such a reference only works for so called well-known assemblies that are listed in a web.config file such as in this case a &lt;b&gt;System.Web.Extensions&lt;/b&gt;. If you use a JavaScript library that comes in a form of a DLL containing multiple JavaScript you may consider listing it in a web.config file and save on assembly name in multiple reference directives.&lt;br /&gt;&lt;h4&gt;IntelliSense Rules&lt;/h4&gt;The JavaScript IntelliSense behavior is determined by the following rules:&lt;ol&gt;&lt;li&gt;Private class members defined inside a class constructor are not visible in IntelliSense. If you need to have IntelliSense support for private members define public getter (get_...) and/or setter (set_...) methods for them with XML comments&lt;/li&gt;&lt;li&gt;Class methods with names beginning with underscore are considered private and not visible even if they have XML comments&lt;/li&gt;&lt;li&gt;Public class methods can be defined in a class prototype or in a standalone code.&lt;/li&gt;&lt;li&gt;If XML comments are not provided only a method name and a list of arguments are displayed.&lt;/li&gt;&lt;/ol&gt;&lt;h4&gt;IntelliSense Errors&lt;/h4&gt;If you don't see IntelliSense support for a JavaScript library even though you have added all the reference check out the Visual Studio &lt;i&gt;Errors&lt;/i&gt; tab. If IntelliSense cannot load a referenced file it will display a message like &lt;i&gt;'Could not load ...'&lt;/i&gt; in the &lt;i&gt;Errors&lt;/i&gt; tab. The most common reasons for IntelliSense not being able to a load a referenced file are:&lt;ul&gt;&lt;li&gt;File is not found at the location or location/file name is invalid. If the file is located on the Internet or a network share there may be a problem accessing those locations from your machine.&lt;/li&gt;&lt;li&gt;A referenced JavaScript file contains errors. If IntelliSense can not successfully parse the file it will not load it.&lt;/li&gt;&lt;li&gt;If a referenced JavaScript is an embedded resource from one of the solution's projects the project is not compiled for some reason and the DLL is not found.&lt;/li&gt;&lt;/ul&gt;&lt;br /&gt;This is all for the first part. In the next post I will explain how to use XML comments in your own JavaScript code to IntelliSense-enable it. If you find something missing or incorrect in this post or have suggestions what else to cover please write a comment and I will get back to you ASAP.&lt;br /&gt;&lt;h3&gt;More to read&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/bb385682.aspx"&gt;JavaScript IntelliSense overview on MSDN&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/06/21/vs-2008-javascript-intellisense.aspx"&gt;Scott Guthrie about JavaScript IntelliSense&lt;/a&gt;&lt;/li&gt;&lt;li&gt;&lt;a href="http://blogs.msdn.com/webdevtools/archive/2007/11/06/jscript-intellisense-a-reference-for-the-reference-tag.aspx"&gt;JScript IntelliSense Reference on WebDevTools Blog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-2667737574768082100?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/C1fixOV7BmM" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-10T10:44:08.186-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://blog.turlov.com/2010/05/leveraging-visual-studio-javascript.html</feedburner:origLink></item><item><title>Automatically compress embedded JavaScript resources with Microsoft Ajax Minifier</title><link>http://feedproxy.google.com/~r/Webnet/~3/baXjQ_Ue_ms/automatically-compress-embedded.html</link><category>JavaScript</category><category>Microsoft Ajax Minifier</category><category>AJAX</category><category>ASP.NET</category><category>CodeProject</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Fri, 14 May 2010 08:03:08 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-9167836250456010153</guid><description>Recently &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/10/15/announcing-microsoft-ajax-library-preview-6-and-the-microsoft-ajax-minifier.aspx"&gt;Microsoft has announced&lt;/a&gt; yet another useful addition to an ASP.NET developer tool belt: Microsoft Ajax Minifier, a tool that enables you to reduce the size of a JavaScript file by removing unnecessary content from it. Clearly this is an extremely useful tool and the ASP.NET development community has gladly embraced it (just google it up to see a lot of positive responses). The tool indeed works very well and there have even been a number of articles comparing it to other well-known JavaScript compression tools that proved its quality. So there are no doubts whether to use the Minifier or not.&lt;br /&gt;
&lt;br /&gt;
The question however is &lt;b&gt;how to use&lt;/b&gt; it. Microsoft Ajax Minifier package does include a set of documentation that explains how to use the tool and even discusses a couple of usage scenarios. Unfortunately the way I wanted to use the Minifier is not covered in the documentation and for some reason I haven't found useful information on the Internet too so I've decided to do some research and share my findings with the community.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;So how would I like to use the Minifier?&lt;/b&gt; Here are the requirements:&lt;ol&gt;&lt;li&gt;I want to automatically compress embedded JavaScript resources in any project of my web application solution.&lt;/li&gt;

&lt;li&gt;I want the compressed JavaScripts have the original names so I don't have to change the references in HTML mark-up.&lt;/li&gt;

&lt;li&gt;I want the compression to be done only when I switch to the Release mode in Visual Studio. When I am in the Debug mode I want all the JavaScript files to be uncompressed for easier debugging.&lt;/li&gt;

&lt;li&gt;I want compressed JavaScript files never overrides the original JavaScript files and I don't want to keep the compressed JavaScripts so whenever I modify my JavaScript code the compressed resources are always up-to-date.&lt;/li&gt;
&lt;/ol&gt;&lt;br /&gt;
&lt;p&gt;I believe that the requirements above describe one of the most common web application solution configuration so if there is a way to achieve them it would be very useful.&lt;/p&gt;&lt;br /&gt;
&lt;p&gt;&lt;b&gt;Can I achieve the requirements above with the Microsoft Ajax Minifier?&lt;/b&gt; The answer is yes. The solution is kind of obvious: since the Microsoft Ajax Minifier includes an MSBuild task I just need to modify a project file where I have embedded JavaScript resources that I need to be compressed to include the Microsoft Ajax Minifier build task. It does not sound complicated and below is the solution which is simple indeed. Just include the following XML in your project file right before the closing &amp;lt;/Project&amp;gt; tag (in most cases):&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;!-- Minify all JavaScript files that were embedded as resources --&amp;gt;
&amp;lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\ajaxmin.tasks" /&amp;gt;
&amp;lt;PropertyGroup&amp;gt;
&amp;lt;ResGenDependsOn&amp;gt;
MinifyJavaScript;
$(ResGenDependsOn)
&amp;lt;/ResGenDependsOn&amp;gt;
&amp;lt;/PropertyGroup&amp;gt;
&amp;lt;Target Name=&amp;quot;MinifyJavaScript&amp;quot; Condition=&amp;quot; '$(ConfigurationName)'=='Release' &amp;quot;&amp;gt;
&amp;lt;Copy SourceFiles=&amp;quot;@(EmbeddedResource)&amp;quot; DestinationFolder=&amp;quot;$(IntermediateOutputPath)&amp;quot; Condition=&amp;quot;'%(Extension)'=='.js'&amp;quot;&amp;gt;
&amp;lt;Output TaskParameter=&amp;quot;DestinationFiles&amp;quot; ItemName=&amp;quot;EmbeddedJavaScriptResource&amp;quot; /&amp;gt;
&amp;lt;/Copy&amp;gt;
&amp;lt;AjaxMin SourceFiles=&amp;quot;@(EmbeddedJavaScriptResource)&amp;quot; SourceExtensionPattern=&amp;quot;\.js$&amp;quot; TargetExtension=&amp;quot;.js&amp;quot; /&amp;gt;
&amp;lt;ItemGroup&amp;gt;
&amp;lt;EmbeddedResource Remove=&amp;quot;@(EmbeddedResource)&amp;quot; Condition=&amp;quot;'%(Extension)'=='.js'&amp;quot; /&amp;gt;
&amp;lt;EmbeddedResource Include=&amp;quot;@(EmbeddedJavaScriptResource)&amp;quot; /&amp;gt;
&amp;lt;FileWrites Include=&amp;quot;@(EmbeddedJavaScriptResource)&amp;quot; /&amp;gt;
&amp;lt;/ItemGroup&amp;gt;
&amp;lt;/Target&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;What this script does is when the solution configuration is 'Release' it finds all the project embedded resource files with the extension '.js' and creates their compressed versions with the same names in the intermediate output folder where they are picked from later by the build process.&lt;/p&gt;&lt;br /&gt;
&lt;h3&gt;A few tips&lt;/h3&gt;&lt;br /&gt;
&lt;p&gt;As you may have noticed the Microsoft Ajax Minifier MSBuild task is referenced from the default folder where it was copied to by the installer. If you want to reference it from a different location, for example if you have a shared development environment and want to have similar setting for everyone, just copy two files ajaxmin.dll and ajaxmintask.dll to another location and include the &amp;lt;UsingTask&amp;gt; tag (below) instead of the &amp;lt;Import&amp;gt; tag in the script above:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;UsingTask TaskName=&amp;quot;AjaxMin&amp;quot; AssemblyFile=&amp;quot;$(MSBuildProjectDirectory)\..\Build\AjaxMinTask.dll&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;The presented script performs so called 'Normal Crunching' (see the Ajax Minifier documentation) of the JavaScript code which already does a pretty good job that is good enough in most of the cases: compression rate is over 50%. If you would like to turn on the 'Hypercrunching' mode (see the Ajax Minifier documentation) you only need to modify one line of the script to include the 'LocalRenaming' option of the Ajax Minifier:&lt;/p&gt;&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;AjaxMin SourceFiles=&amp;quot;@(EmbeddedJavaScriptResource)&amp;quot; SourceExtensionPattern=&amp;quot;\.js$&amp;quot; TargetExtension=&amp;quot;.js&amp;quot; LocalRenaming=&amp;quot;CrunchAll&amp;quot; /&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;p&gt;And the last note is: don't use the default &lt;i&gt;Hypercrunching&lt;/i&gt; mode or &lt;i&gt;RemoveUnneededCode&lt;/i&gt; option with the ASP.NET AJAX Framework as it does not work properly with it.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-9167836250456010153?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/baXjQ_Ue_ms" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-14T11:03:08.599-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">3</thr:total><feedburner:origLink>http://blog.turlov.com/2009/11/automatically-compress-embedded.html</feedburner:origLink></item><item><title>Using the Microsoft Ajax Library 3.5 with the CDN</title><link>http://feedproxy.google.com/~r/Webnet/~3/rdDCY4Fb3b4/using-microsoft-ajax-library-35-with.html</link><category>CDN</category><category>AJAX</category><category>ASP.NET</category><category>CodeProject</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Fri, 14 May 2010 08:04:31 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-3262810992561534220</guid><description>Recently &lt;a href="http://weblogs.asp.net/scottgu/archive/2009/09/15/announcing-the-microsoft-ajax-cdn.aspx"&gt;Microsoft has announced&lt;/a&gt; its &lt;a href="http://www.asp.net/ajax/CDN/Default.aspx"&gt;Microsoft Ajax content delivery network (CDN)&lt;/a&gt; which can significantly improve the performance of any ASP.NET AJAX web application. When it was first announced the CDN was almost useless for the current web applications based on ASP.NET 3.5 since it did not host the Microsoft Ajax library 3.5 and did not support content delivery via SSL. However in a very short period of time Microsoft was able to fix those problems (good job!) and now web applications built on ASP.NET 3.5 can benefit from using Microsoft Ajax CDN.&lt;br /&gt;
&lt;br /&gt;
So how do you make &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; file being referenced from the CDN as opposed to the embedded file? Quite easy actually with the help of the &lt;i&gt;ScriptManager&lt;/i&gt; control. Add the following declaration to a page (or Master page) where there is a ScriptManager control:&lt;br /&gt;
&lt;script type="syntaxhighlighter" class="brush: xhtml"&gt;
&lt;asp:scriptmanager runat="server" enablepartialrendering="false"&gt;
&lt;scripts&gt;
&lt;asp:scriptreference name="MicrosoftAjax.js" path="http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js" /&gt;
&lt;/scripts&gt;
&lt;/asp:ScriptManager&gt;
&lt;/script&gt;&lt;br /&gt;
What that declaration means is that the script with a name &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; which is always automatically referenced by a &lt;i&gt;ScriptManager&lt;/i&gt; from the &lt;i&gt;System.Web.Extensions&lt;/i&gt; dll now should be referenced from that location: &lt;i&gt;http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
This is how it is referenced by default:&lt;br /&gt;
&lt;pre class="brush: xhtml"&gt;&amp;lt;script src="/ScriptResource.axd?d=eYUqBJhfSVL41hIDYkBL0tfaps9hoQId_48PydfbcyWH41vNvL68sk-l7P9FLAPz7b4vtI8WkZ-ezAF0b_ZkyG52wt9oUtaQ5ezFfGBr7LY1&amp;amp;t=ffffffffef976216" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
and after we include the new &lt;i&gt;ScriptReference&lt;/i&gt; declaration:&lt;br /&gt;
&lt;pre class="brush: xhtml"&gt;&amp;lt;script src="http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
&lt;i&gt;ScriptManager&lt;/i&gt; is even smart enough to automatically reference the debug version &lt;i&gt;MicrosoftAjax.debug.js&lt;/i&gt; from the CDN when debugging is enabled in the web.config file:&lt;br /&gt;
&lt;pre class="brush: xml"&gt;&amp;lt;compilation debug="true"&amp;gt;
&lt;/pre&gt;&lt;pre class="brush: xhtml"&gt;&amp;lt;script src="http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.debug.js" type="text/javascript"&amp;gt;&amp;lt;/script&amp;gt;
&lt;/pre&gt;&lt;br /&gt;
So this is clear: we have our &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; referenced from the CDN and that improves our web application performance and saves us and the visitors some bandwidth since an internet browser will reuse the same cached copy of the &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; from the CDN for different web applications that reference it.&lt;br /&gt;
&lt;h3&gt;Using the CDN conditionally&lt;/h3&gt;What if we only wanted to reference &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; from the CDN when the web application is deployed to a production environment and use an embedded version in a development environment? That would make sense in order for the developers to work without having to be connected to the Internet. Once again it can be done but this time we'll need to write some code. We are going to add the &lt;i&gt;MicrosoftAjax.js&lt;/i&gt; script reference dynamically depending on the &lt;i&gt;debug&lt;/i&gt; value in the web.config file; we only add the script reference when &lt;i&gt;debug="false"&lt;/i&gt;:&lt;script type="syntaxhighlighter" class="brush: csharp"&gt;
protected void Page_Load(object sender, EventArgs e)
{
if (!Context.IsDebuggingEnabled)
{
ScriptManager sm = ScriptManager.GetCurrent(this);
sm.Scripts.Add(new ScriptReference {Name = "MicrosoftAjax.js", Path = "http://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js"});
}
}
&lt;/script&gt;&lt;br /&gt;
&lt;h3&gt;Using the CDN via SSL&lt;/h3&gt;Another major case is when our web application has pages that are served via SSL. In this case we want to automatically select the correct CDN URL for the &lt;i&gt;MicrosoftAjax.js&lt;/i&gt;. In order to do that we just modify the previous code:&lt;br /&gt;
&lt;script type="syntaxhighlighter" class="brush: csharp"&gt;
protected void Page_Load(object sender, EventArgs e)
{
if (!Context.IsDebuggingEnabled)
{
ScriptManager sm = ScriptManager.GetCurrent(this);
sm.Scripts.Add(new ScriptReference {Name = "MicrosoftAjax.js", Path = Request.Url.Scheme + "://ajax.microsoft.com/ajax/3.5/MicrosoftAjax.js"});
}
}
&lt;/script&gt;So that's it for now. Enjoy using the Microsoft Ajax CDN.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-3262810992561534220?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/rdDCY4Fb3b4" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-14T11:04:31.994-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.turlov.com/2009/11/using-microsoft-ajax-library-35-with.html</feedburner:origLink></item><item><title>Talk about P&amp;P Web Client Software Factory on Toronto Architecture User Group meeting</title><link>http://feedproxy.google.com/~r/Webnet/~3/LXAj6ZIsT10/talk-about-p-web-client-software.html</link><category>Guidance Automation</category><category>WCSF</category><category>patterns and practices</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Thu, 08 Oct 2009 13:40:57 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-6382636590019952252</guid><description>Developing modular web applications is a popular topic in development communities especially after ASP.NET MVC framework has been introduced by Microsoft. However ASP.NET MVC is not the first and only framework that can help on that way.&lt;br /&gt; &lt;br /&gt;I'll be talking about building modular enterprise-class modern web applications with the help of &lt;a href="http://www.martinfowler.com/eaaDev/uiArchs.html#model-view-presentermvp"&gt;MVP design pattern&lt;/a&gt; and Microsoft Patterns and Practices &lt;a href="http://websf.codeplex.com/"&gt;Web Client Software Factory&lt;/a&gt; framework on the next meeting of &lt;a href="http://www.architectureug.com/"&gt;Toronto Architecture User Group&lt;/a&gt; on Thursday October 29th. To attend please &lt;a href="https://www.clicktoattend.com/invitation.aspx?code=142060"&gt;register online here&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-6382636590019952252?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/LXAj6ZIsT10" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-10-08T16:40:57.905-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2009/10/talk-about-p-web-client-software.html</feedburner:origLink></item><item><title>Problem with Internet Explorer 8 Debugger on Windows 7</title><link>http://feedproxy.google.com/~r/Webnet/~3/TlybIlsAZDU/problem-with-internet-explorer-8.html</link><category>Internet browsers</category><category>Windows 7</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 23 Sep 2009 11:30:06 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-121603264159396581</guid><description>I continue to evaluate Windows 7 after upgrading from Windows Vista and share some experience (mostly bad of course, so people would not step on the same problem again). &lt;a href="http://blog.turlov.com/2009/09/how-to-map-iso-file-to-drive-in-windows.html"&gt;As I mentioned before&lt;/a&gt;, overall upgrade was smooth and mostly everything works OK. However time to time I stumble upon some really annoying problems that did not exist on Windows Vista and therefore need to be solved for Windows 7 from scratch.&lt;br /&gt;&lt;br /&gt;One of the recent problems was &lt;a href="http://blog.turlov.com/2009/09/how-to-map-iso-file-to-drive-in-windows.html"&gt;Daemon Tools not working on Windows 7&lt;/a&gt; and it was solved by installing Magic Disc. Now there is one more thing: after upgrading to Windows 7 I am not able to use IE8 Debugger. When I pressed F12 the Debugger icon appeared on the task bar but I can not switch to its window: it's not visible.&lt;br /&gt;&lt;br /&gt;So obviously I searched over the Internet and luckily there was one post on &lt;a href="http://stackoverflow.com/questions/960683/why-isnt-my-ie8-developer-tools-working"&gt;Stack Overflow&lt;/a&gt; (apart from those guessing about a window being outside of the screen) that suggested that there may be some wrong setting in Windows registry. And there are some registry keys related to IE8 debugger! So the solution was to &lt;span style="font-weight:bold;"&gt;remove WindowsPos, Pinned and UseDevToolsDebugger keys&lt;/span&gt; from the [HKEY_CURRENT_USER\Software\Microsoft\Internet Explorer\IEDevTools] section. That completely solved the problem.&lt;br /&gt;&lt;br /&gt;Unfortunately I can not tell whether those keys existed in Windows Vista and were incompatible with Windows 7 or their values have been incorrectly modified during the upgrade. But after removing them and starting IE8 debugger they haven't appeared again. So probably they are not needed anymore.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-121603264159396581?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/TlybIlsAZDU" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-23T14:30:06.764-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.turlov.com/2009/09/problem-with-internet-explorer-8.html</feedburner:origLink></item><item><title>How to map .ISO file to a drive in Windows 7</title><link>http://feedproxy.google.com/~r/Webnet/~3/TxagGYAiUjU/how-to-map-iso-file-to-drive-in-windows.html</link><category>Windows 7</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Thu, 17 Sep 2009 07:38:20 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-801207542971014249</guid><description>So, recently I have upgraded my laptop from Windows Vista to Windows 7. The upgrade process was straight forward and flawless and everything so far was OK except one thing: the &lt;a href="http://www.disc-tools.com/download/daemon"&gt;Daemon Tools&lt;/a&gt; that I've been using for mapping .ISO image files since 2004 on various Windows systems refuses to work on Windows 7. Even Windows 7 compatibility mode does not help: Daemon Tools manages to recognize Windows 7 anyways. Luckily there is another tool that provides with absolutely the same functionality and also free: &lt;a href="http://www.magiciso.com/tutorials/miso-magicdisc-history.htm"&gt;Magic Disc&lt;/a&gt;. It works under Windows 7 flawlessly and really makes my life easier: no need to burn ISO files on CD/DVD anymore.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-801207542971014249?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/TxagGYAiUjU" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-17T10:38:20.636-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">1</thr:total><feedburner:origLink>http://blog.turlov.com/2009/09/how-to-map-iso-file-to-drive-in-windows.html</feedburner:origLink></item><item><title>ASP.NET user name availability check using WCSF Validation Bundle</title><link>http://feedproxy.google.com/~r/Webnet/~3/Wcfkvb9TC6k/aspnet-user-name-availability-check.html</link><category>AJAX</category><category>ASP.NET</category><category>WCSF</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 18 Nov 2009 11:48:23 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-4965728259954930567</guid><description>An average web site offering membership and protected content for its members requires users to sign up by visiting a sign-up or register page that allows a user to enter some information and create an account. A couple of pieces if information that users are commonly asked to enter are a User name or Login name and user's email. One potential problem with such user input is checking that entered login name and/or email address are available for registration and haven't been used by other users. When it's the case multiple attempts of entering available values can be very annoying and frustrating for users even making them to refuse registration on a web site. So improving user experience when validating login name and email is quite an important task.&lt;br /&gt;&lt;br /&gt;There is a number of ways of how to implement a user input validation and display an error message, for instance &lt;a href="http://encosia.com/2007/07/02/aspnet-username-availability-checking-via-ajax/"&gt;that one suggested by Dave Ward&lt;/a&gt;. In this post I am going to show you another relatively simple and elegant solution that provides with both  reliability and reasonably pleasant user experience.&lt;br /&gt;&lt;br /&gt;The solution is based on using a &lt;a href="http://msdn.microsoft.com/en-us/library/cc304908.aspx"&gt;ServerSideValidationExtender control&lt;/a&gt; from &lt;a href="http://websf.codeplex.com/Wiki/View.aspx?title=Validation_landing_page&amp;amp;referringTitle=Home"&gt;Web Client Software Factory validation bundle&lt;/a&gt;. The &lt;i&gt;ServerSideValidationExtender&lt;/i&gt; control allows asynchronious invocation of a server-side validation handler that performs a validation right after a user finished entering data without a postback thus signifcantly improving the user experience at the same time leveraging robustness and security of server-side validation.&lt;br /&gt;&lt;h3&gt;Code example&lt;/h3&gt;For this example I will be using a really simple markup code:&lt;br /&gt;&lt;pre class="brush: xhtml"&gt;&lt;br /&gt;&amp;lt;asp:Label ID="lblEmail" runat="server" Text="Email: "&gt;&lt;/asp:Label&gt;&lt;br /&gt;&amp;lt;asp:TextBox ID="txtEmail" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&amp;lt;asp:CustomValidator ID="cvEmail" runat="server"&lt;br /&gt;    ErrorMessage="Email is already used"&lt;br /&gt;    ControlToValidate="txtEmail"&lt;br /&gt;    onservervalidate="cvEmail_ServerValidate" /&gt;&lt;br /&gt;&amp;lt;wcsf:ServerSideValidationExtender ID="ssveEmail" &lt;br /&gt;    TargetControlID="cvEmail" &lt;br /&gt;    ValidateEmptyText="false" runat="server" /&gt;&lt;br /&gt;&amp;lt;br /&gt;    &lt;br /&gt;&amp;lt;asp:Label ID="lblLogin" runat="server" Text="Login: "&gt;&lt;/asp:Label&gt;&lt;br /&gt;&amp;lt;asp:TextBox ID="txtLogin" runat="server"&gt;&lt;/asp:TextBox&gt;&lt;br /&gt;&amp;lt;asp:CustomValidator ID="cvLogin" runat="server"&lt;br /&gt;    ErrorMessage="Login name is already used" &lt;br /&gt;    ControlToValidate="txtLogin"&lt;br /&gt;    onservervalidate="cvEmail_ServerValidate" /&gt;&lt;br /&gt;&amp;lt;wcsf:ServerSideValidationExtender ID="ssveLogin" &lt;br /&gt;    TargetControlID="cvLogin" &lt;br /&gt;    ValidateEmptyText="false" runat="server" /&gt;&lt;br /&gt;&amp;lt;br /&gt;&lt;br /&gt;&amp;lt;asp:Button ID="cmdRegister" runat="server" Text="Register" /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;that effectively results in that UI in a browser:&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_wYfdNSEIRks/SkJdLe50ZWI/AAAAAAAAADE/DSKkDTzPYb4/s1600-h/ssvePic1.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 309px; height: 222px;" src="http://2.bp.blogspot.com/_wYfdNSEIRks/SkJdLe50ZWI/AAAAAAAAADE/DSKkDTzPYb4/s400/ssvePic1.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5350941759125087586" /&gt;&lt;/a&gt;&lt;br /&gt;For each &lt;i&gt;TextBox&lt;/i&gt; control requiring asynchronious server-side validation I've added a &lt;i&gt;CustomValidator&lt;/i&gt; control and a &lt;i&gt;ServerSideValidationExtender&lt;/i&gt; that has its &lt;i&gt;TargetID&lt;/i&gt; property set to an ID of a corresponding &lt;i&gt;CustomValidator&lt;/i&gt; control.&lt;br /&gt;&lt;br /&gt;Next I've added some code to the validation handlers for the &lt;i&gt;CustomValidator&lt;/i&gt; controls to the page's code behind and that's it:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;protected void cvEmail_ServerValidate(object source, &lt;br /&gt;    ServerValidateEventArgs args)&lt;br /&gt;{&lt;br /&gt;  args.IsValid = string.IsNullOrEmpty(&lt;br /&gt;          Membership.GetUserNameByEmail(args.Value));&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;protected void cvLogin_ServerValidate(object source, &lt;br /&gt;    ServerValidateEventArgs args)&lt;br /&gt;{&lt;br /&gt;  args.IsValid = Membership.GetUser(args.Value) == null;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that the &lt;i&gt;IsValid&lt;/i&gt; equals true when a user can not be found. The server-side validation handler is being executed asynchroniously every time a corresponding &lt;i&gt;TextBox&lt;/i&gt; loses its focus and if validation has failed (meaning that a user was found and login name or email is not available) a corresponding error message is displayed immediately on the page without a postback so a user does not have to click a submit button and wait for the page to render again to see the result of the validation.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://2.bp.blogspot.com/_wYfdNSEIRks/SkJdLStMgvI/AAAAAAAAADM/BJX2zjZ2APE/s1600-h/ssvePic2.gif"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 200px;" src="http://2.bp.blogspot.com/_wYfdNSEIRks/SkJdLStMgvI/AAAAAAAAADM/BJX2zjZ2APE/s400/ssvePic2.gif" border="0" alt=""id="BLOGGER_PHOTO_ID_5350941755850916594" /&gt;&lt;/a&gt;&lt;br /&gt;The only trick here is that in the server-side validation handler we can only access a value of the control being validated because values of other controls on the page haven't been updated on the server side (no postback, remember?!).&lt;br /&gt;&lt;br /&gt;&lt;i&gt;Note&lt;/i&gt;. In the production code you may want to add some layout and styling to your HTML markup, and of course there will be perhaps other input boxes on a form with may be more validator controls but the approach won't change: no additional code required, the same well-known validation pattern but with nicer user experience. I would also recommend to implement a simple but very useful change to the &lt;i&gt;ServerSideValidationExtender&lt;/i&gt; control suggested by &lt;a href="http://elegantcode.com/2008/01/29/wcsf-client-side-validation-tweaks" target="_blanc"&gt;Jarod Ferguson&lt;/a&gt;.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-4965728259954930567?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/Wcfkvb9TC6k" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T14:48:23.509-05:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/_wYfdNSEIRks/SkJdLe50ZWI/AAAAAAAAADE/DSKkDTzPYb4/s72-c/ssvePic1.gif" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">4</thr:total><feedburner:origLink>http://blog.turlov.com/2009/06/aspnet-user-name-availability-check.html</feedburner:origLink></item><item><title>How to set programmatically a value of a watermarked TextBox via JavaScript</title><link>http://feedproxy.google.com/~r/Webnet/~3/Z6K90kw--Hk/how-to-programmatically-set-value-of.html</link><category>AJAX</category><category>ASP.NET</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 12 May 2010 09:08:34 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-8471929399420311533</guid><description>&lt;div style="background-color:#eee; border:1px dotted #777;padding:3px"&gt;There is an updated version of the article for the latest Ajax Control Toolkit release: &lt;a href="http://blog.turlov.com/2010/05/how-to-set-programmatically-value-of.html"&gt;http://blog.turlov.com/2010/05/how-to-set-programmatically-value-of.html&lt;/a&gt; &lt;/div&gt;&lt;br /&gt;If you use &lt;a href="http://www.asp.net/ajax/" target="_blanc"&gt;ASP.NET AJAX&lt;/a&gt; and &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Default.aspx" target="_blanc"&gt;AJAX Control Toolkit&lt;/a&gt; you may find it useful to decorate some of your TextBox controls on a page with a &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/TextBoxWatermark/TextBoxWatermark.aspx" target="_blanc"&gt;TextBoxWatermark AJAX extender control&lt;/a&gt; from the AJAX Control Toolkit. It's fairly easy to use and a nice tool for improving both the page look and user experience.&lt;br /&gt;&lt;br /&gt;However if you need to set a value of a TextBox decorated with the TextBoxWatermark extender programmatically via JavaScript on the client-side you may notice that the behavior of the watermarked TextBox is different. If you use the regular way to set a value like this:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;$get(textBoxId).value = someText;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;then the value displayed in the TextBox on the page will change to the set value but the watermarked look will still be present and other AJAX Control Toolkit TextBox extenders (like a &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Calendar/Calendar.aspx" target="_blanc"&gt;Calendar extender&lt;/a&gt;, for instance) will not recognize the new value.&lt;br /&gt;&lt;br /&gt;This happens because the TextBoxWatermark extender can not recognize and intercept your JavaScript operation since it's designed to serve user interactions. However there is a correct way of programmatic access to the TextBox's value. We modify the code above like that:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;var textBox = $get(textBoxId);&lt;br /&gt;if (textBox.AjaxControlToolkitTextBoxWrapper) {&lt;br /&gt;    textBox.AjaxControlToolkitTextBoxWrapper.set_Value(someText);&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;    textBox.value = someText;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The explanation is that most of the TextBox extenders from the AJAX Control Toolkit including a TextBoxWatermark extender use a special proxy class &lt;i&gt;AjaxControlToolkitTextBoxWrapper&lt;/i&gt; to manipulate with the &lt;span style="font-style:italic;"&gt;input&lt;/span&gt; elements. The proxy adds a special property &lt;i&gt;AjaxControlToolkitTextBoxWrapper&lt;/i&gt; to the &lt;i&gt;input&lt;/i&gt; element that contains a reference to itself allowing to access the value of the &lt;i&gt;input&lt;/i&gt; element correctly. Similarly, if you need to get a value of a watermarked TextBox you do it like this:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;var textBox = $get(textBoxId), text;&lt;br /&gt;if (textBox.AjaxControlToolkitTextBoxWrapper) {&lt;br /&gt;    text = textBox.AjaxControlToolkitTextBoxWrapper.get_Value();&lt;br /&gt;}&lt;br /&gt;else {&lt;br /&gt;    text = textBox.value;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-8471929399420311533?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/Z6K90kw--Hk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-05-12T12:08:34.825-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.turlov.com/2009/06/how-to-programmatically-set-value-of.html</feedburner:origLink></item><item><title>New version of ASP.NET AJAX Control Toolkit released</title><link>http://feedproxy.google.com/~r/Webnet/~3/iCeboM2n3vc/new-version-of-aspnet-ajax-control.html</link><category>Color Picker Extender</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 03 Jun 2009 11:40:56 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-5554215373683993915</guid><description>The &lt;a href="http://ajaxcontroltoolkit.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27326"&gt;new release of ASP.NET AJAX Control Toolkit&lt;/a&gt; is available for download. Bertrand Le Roy has written a &lt;a href="http://weblogs.asp.net/bleroy/archive/2009/05/13/new-release-of-the-ajax-control-toolkit.aspx"&gt;very informative post&lt;/a&gt; about it. What particularly concerns me in this new release is that a &lt;a href="http://cpe.codeplex.com/"&gt;Color Picker extender&lt;/a&gt; is now &lt;a href="http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ColorPicker/ColorPicker.aspx"&gt;included in the Ajax Control Toolkit&lt;/a&gt;. Hooray!&lt;br /&gt;&lt;br /&gt;Along with the new Toolkit release there come a whole bunch of new &lt;a href="http://www.asp.net/learn/ajax"&gt;tutorials&lt;/a&gt; and videos among them there are one &lt;a href="http://www.asp.net/learn/Ajax-Control-Toolkit/tutorial-51-cs.aspx"&gt;particularly nice tutorial about the Color Picker extender&lt;/a&gt; and an &lt;a href="http://www.asp.net/learn/ajax-videos/video-7113.aspx"&gt;excellent video tutorial&lt;/a&gt; by Joe Stagner. Thank you folks for such a great job!&lt;br /&gt;&lt;br /&gt;What that means for the Color Picker Extender users is that they don't have to download it separately from &lt;a href="http://cpe.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=17713"&gt;Codeplex&lt;/a&gt; anymore because it is included in the Ajax Control Toolkit. For those who can not switch to the new version of ACT yet the original Color Picker Extender control will continue to be available on Codeplex. During the next few days I will prepare and upload a new release synced up with the Ajax Control Toolkit.&lt;br /&gt;&lt;br /&gt;It is also very interesting to read people's opinions about the new release of ACT that they write in response to blog posts and on Codeplex. In general the responses are positive however some folks complain about something, mostly about insignificant things or because they missed something. I would like to remind everybody that Ajax Control Toolkit is completely a community initiative (with of course the initial kick-off help from Microsoft) and people who work on it take time for it out of their families and other important things so let's be more tolerant and if you've come across something really bad please use &lt;a href="http://ajaxcontroltoolkit.codeplex.com/WorkItem/List.aspx"&gt;the Issue Tracker&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;In particular I was interested in reading responses about the ColorPicker (but of course ;-)). Interestingly all the complaints were about how its look and feel, not about functionality. I admit that the UI it provides is rather simplistic but here is my question back: where have you all folks been since the control was published almost a year ago and I was asking for your feedbacks and suggestions? Since then it's been downloaded more then 2000 times (and I don't count downloads of ACT source code) and almost no one except just a few people suggested anything about improving it. I take it as everybody has been satisfied. However now with a bit more visibility I suggest if you folks really want some progress with what concerns you please speak up.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-5554215373683993915?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/iCeboM2n3vc" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-06-03T14:40:56.212-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2009/06/new-version-of-aspnet-ajax-control.html</feedburner:origLink></item><item><title>Survey: Ajax usage among .NET developers</title><link>http://feedproxy.google.com/~r/Webnet/~3/U4WLGgBCBsw/survey-ajax-usage-among-net-developers.html</link><category>AJAX</category><category>ASP.NET</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 27 May 2009 11:29:20 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-6402913414519919360</guid><description>If you haven’t already and you are a .NET developer, please take a couple minutes and answer this survey, whether you use Ajax or not. There are a number of Ajax surveys around, but this is the only one that focuses on .NET developers.&lt;br /&gt;&lt;br /&gt;The survey: &lt;br /&gt;&lt;a href="http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H" target="_blanc"&gt;http://www.zoomerang.com/Survey/?p=WEB22973CYKW2H&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-6402913414519919360?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/U4WLGgBCBsw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-27T14:29:20.358-04:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2009/05/survey-ajax-usage-among-net-developers.html</feedburner:origLink></item><item><title>Enabling a WCSF solution for sub-Web Application Project</title><link>http://feedproxy.google.com/~r/Webnet/~3/X-rszkiJblw/enabling-wcsf-solution-for-sub-web.html</link><category>Guidance Automation</category><category>ASP.NET</category><category>WCSF</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Fri, 01 May 2009 13:34:42 PDT</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-5611643284274261801</guid><description>If in your &lt;a href="http://msdn.microsoft.com/en-us/library/bb264518.aspx"&gt;WCSF&lt;/a&gt; solution you use Web Application Project (as opposed to Web Site Project) for your web site you are able to &lt;a href="http://msdn.microsoft.com/en-us/library/cc304702.aspx"&gt;use a so called sub-Web Application Project&lt;/a&gt; in order to further modularize your web application.&lt;br /&gt;&lt;br /&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://3.bp.blogspot.com/_wYfdNSEIRks/SftawHwtnJI/AAAAAAAAACs/KVPJcxPGL9Y/s1600-h/wcsf_subweb.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 288px;" src="http://3.bp.blogspot.com/_wYfdNSEIRks/SftawHwtnJI/AAAAAAAAACs/KVPJcxPGL9Y/s400/wcsf_subweb.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5330954366686698642" /&gt;&lt;/a&gt;&lt;br /&gt;If you created a WAP WCSF solution from scratch this option will be available to your all right. However if you converted your Web Site WCSF solution to WAP WCSF solution or &lt;a href="http://blog.turlov.com/2008/05/upgrading-your-wcsf-solution-from-june.html"&gt;upgraded from the previous version of WCSF&lt;/a&gt; this option may not appear when you are trying to add a new business module to your solution.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Visibility of the "Create as sub-Web Application Project" checkbox depends on one single property of a solution file and if you don't see the checkbox open the .sln file with any text editor and check out that it contains the follwoing content:&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;GlobalSection(ExtensibilityGlobals) = postSolution&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;...&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(255, 0, 0);"&gt;IsWCSFSolutionWAP = True&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt;  &lt;/span&gt;...&lt;/div&gt;&lt;div&gt;&lt;span class="Apple-tab-span" style="white-space:pre"&gt; &lt;/span&gt;EndGlobalSection&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;Usually this section is located in the bottom of a .sln file and the red line is the key to solving the problem. If you don't see the line in your solution file simply add it and reload the solution in Visual Studio. Problem solved.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-5611643284274261801?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/X-rszkiJblw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-05-01T16:34:42.991-04:00</app:edited><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/_wYfdNSEIRks/SftawHwtnJI/AAAAAAAAACs/KVPJcxPGL9Y/s72-c/wcsf_subweb.png" height="72" width="72" /><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2009/05/enabling-wcsf-solution-for-sub-web.html</feedburner:origLink></item><item><title>How to Improve ASP.NET UpdatePanel Performance</title><link>http://feedproxy.google.com/~r/Webnet/~3/Qv6ILAGE32c/how-to-improve-aspnet-updatepanel.html</link><category>AJAX</category><category>ASP.NET</category><category>CodeProject</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 28 Dec 2010 14:33:11 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-1891726834682575819</guid><description>Since ASP.NET AJAX UpdatePanel was first introduced it has earned a strange mix of reputation. From one hand it has become a tool of first choice for many ASP.NET developers who wanted an easy way of introducing an AJAX-like behavior for their ASP.NET web apps. From another hand it has earned a lot of criticism from seasoned web developers because of certain performance consequences associated with complex usage scenarios.&lt;br /&gt;
&lt;br /&gt;
Well everything may be good and may be evil based on how we use it. From my experience consious and judicious use of UpdatePanel is the key to saving its benefits and avoiding potential problems.&lt;br /&gt;
&lt;br /&gt;
Below I suggest a number of rules that help achieving better results when using UpdatePanel.&lt;ul&gt;&lt;li&gt;Avoid automatic refreshing of UpdatePanel; always stay in control of which UpdatePanel and when refreshes: set &lt;b&gt;UpdateMode&lt;/b&gt; property to &lt;b&gt;Conditional&lt;/b&gt; (the default value is Always).&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Minimize the content of the UpdatePanel: the &amp;lt;ContentTemplate&amp;gt; should only include controls that are neccessary to refresh. For instance if user input requires server-side validation include only an error message mark-up in the UpdatePanel and leave the rest of the form outside.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Try to keep the partial postback trigger controls outside of their respective UpdatePanels unless its neccessary to change their markup.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Try to stick to a simple rule: one trigger for one UpdatePanel. If you need to refresh multiple UpdatePanels during one request add a trigger control to only one of those UpdatePanels and refresh the others programmatically in an event handler on the server. The idea is to avoid uncontrollable refreshing of unnecessary UpdatePanels.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Since ViewState is updated with every partial postback request turn the ViewState off on a page that contains the UpdatePanel wherever possible or store the ViewState on the server to avoid transferring it forth and back with every async request.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;Since Page runs through its lifecycle during every partial postback and executes methods like Page_Load or Page_PreRender make sure that logic that is unneccessary for refreshing UpdatePanel is not executed by wrapping it in &lt;i&gt;if(!ScriptManager.IsInAsyncPostBack)&lt;/i&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;If you use UpdatePanel event handlers like Init, Load, PreRender and Unload make sure that code inside these event handlers does not execute unless neccessary by checking &lt;i&gt;Page.IsPostBack&lt;/i&gt; and &lt;i&gt;ScriptManager.IsInAsyncPostBack&lt;/i&gt; properties.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;If you trigger an UpdatePanel programmatically from the client-side (via JavaScript) make sure that its event handler check for the event trigger value using &lt;i&gt;Request.Params["__EVENTTARGET"]&lt;/i&gt; ot avoid unnecessary execution path.&lt;br /&gt;
&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;If you programmatically update Page's Header (Title, etc.) or other Page's content that is outside UpdatePanel make sure that this code &lt;b&gt;never&lt;/b&gt; gets executed during partial postbacks. First of all its not neccessary since page does not refresh but also it may be dangerous because the content may not be handled properly by a browser.&lt;/li&gt;
&lt;/ul&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;There may probably be more tricks and tips regarding usage of UpdatePanel but those mentioned above have been proven by real exeprience. I would also recommend reading an &lt;a href="http://encosia.com/2007/10/24/are-you-making-these-3-common-aspnet-ajax-mistakes/"&gt;excellent post&lt;/a&gt; by &lt;b&gt;&lt;i&gt;Dave Ward&lt;/i&gt;&lt;/b&gt; that helps understanding how UpdatePanel works behind the scene and never hesitate using Fiddler to investigate what your web app's doing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-1891726834682575819?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/Qv6ILAGE32c" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2010-12-28T17:33:11.579-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2009/02/how-to-improve-aspnet-updatepanel.html</feedburner:origLink></item><item><title>Using ColorPickerExtender Client-side Events</title><link>http://feedproxy.google.com/~r/Webnet/~3/UrcD3TIoH0k/using-colorpickerextender-client-side.html</link><category>Color Picker Extender</category><category>ASP.NET</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Fri, 20 Nov 2009 08:25:35 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-6859556165800156565</guid><description>There have been question about how to utilize the client-side functionality of the ColorPickerExtender in order to improve customer experience. Here is an example of how to use a &lt;b&gt;colorSelectionChanged&lt;/b&gt; client event.&lt;h3&gt;Subscribing to the &lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;colorSelectionChanged &lt;/span&gt;event&lt;/h3&gt;You can subscribe to the event either via JavaScript code or ASP.NET mark-up:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;    var cpe = $find("ColorPickerExtender1");&lt;br /&gt;    cpe.add_colorSelectionChanged(changeColor);&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Here &lt;i&gt;$find&lt;/i&gt; is a standard function of the ASP.NET AJAX Framework that returns an instance of the AJAX component by &lt;i&gt;BehaviourID&lt;/i&gt;; &lt;i&gt;ColorPickerExtender1&lt;/i&gt; is a &lt;i&gt;BehaviourID&lt;/i&gt; of the ColorPickerExtender component and &lt;i&gt;changeColor&lt;/i&gt; is your JavaScript function that will be called when the event occurs.&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&amp;lt;ajaxToolkit:ColorPickerExtender ID="defaultCPE" runat="server"&lt;br /&gt;    TargetControlID="Color1"&lt;br /&gt;    BehaviorID="ColorPicker1"&lt;br /&gt;    OnClientColorSelectionChanged="changeColor"&lt;br /&gt;/&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Make sure that the &lt;i&gt;changeColor&lt;/i&gt; JavaScript function exists on the page otherwise you'll see a JavaScript error "changeColor is undefined". You may define a &lt;i&gt;changeColor&lt;/i&gt; function like this:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;function changeColor(sender) {&lt;br /&gt;    sender.get_element().style.color = "#" + sender.get_selectedColor();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;When your function is called after a user picked a color (i.e. clicked a mouse on the color palette) a &lt;i&gt;sender&lt;/i&gt; argument will point to the instance of the &lt;i&gt;ColorPickerExtender&lt;/i&gt; component that you can use inside your function. For instance, call a method &lt;i&gt;get_element()&lt;/i&gt; to retrieve a reference to an &lt;i&gt;input&lt;/i&gt; DOM element which the extender is attached to or use a &lt;i&gt;get_selectedColor()&lt;/i&gt; method to retrieve a hexadecimal color code that the user selected. When assigning the color value to a DOM element style don't forget to prepend it with a &lt;b&gt;'#'&lt;/b&gt; character.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-6859556165800156565?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/UrcD3TIoH0k" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-20T11:25:35.388-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">2</thr:total><feedburner:origLink>http://blog.turlov.com/2009/03/using-colorpickerextender-client-side.html</feedburner:origLink></item><item><title>ASP.NET AJAX Compatibility Patch for Safari 3.x and Google Chrome</title><link>http://feedproxy.google.com/~r/Webnet/~3/FDgla2ss-Fk/aspnet-ajax-compatibility-patch-for.html</link><category>AJAX</category><category>ASP.NET</category><category>AJAX Control Toolkit</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Wed, 18 Nov 2009 12:08:50 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-9173821638965454218</guid><description>The problem I am going to talk about is not new but it somehow managed to concern not so many developers so far. However it is a growing concern and more people would need a solution at some point.&lt;br /&gt;&lt;br /&gt;The heart of the problem is there are two browsers with a groing number of users - Safari 3.x and Google Chrome, that ASP.NET AJAX framework is not compatible with. One part of the problem is induced by a fact that both browsers report themselves as "Webkit" which is not supported by ASP.NET AJAX. This part of the problem affects both Safari and Chrome users. The second part of the problem mostly affects Safari users because ASP.NET AJAX framework does "support" Safari (version 2.x) but in such a manner that makes your web application look a total disaster in Safari version 3.x. The suggested fix will help both cases. At least my tests showed quite a success.&lt;br /&gt;&lt;br /&gt;Ideally we would need an official patch from Microsoft but since they have their own plans and busy with the next .NET/ASP.NET 4.0 and VS 2010 I would assume that there will be no fix till those versions are out. So let's stick to this solution for now.&lt;br /&gt;&lt;br /&gt;The solutions for the problem were suggested by a couple of people: &lt;a href="http://forums.asp.net/p/1252014/2898429.aspx"&gt;http://forums.asp.net/p/1252014/2898429.aspx&lt;/a&gt; and &lt;a href="http://blog.lavablast.com/post/2008/10/Gotcha-WebKit-(Safari-3-and-Google-Chrome)-Bug-with-ASPNET-AJAX.aspx"&gt;http://blog.lavablast.com/post/2008/10/Gotcha-WebKit-(Safari-3-and-Google-Chrome)-Bug-with-ASPNET-AJAX.aspx&lt;/a&gt;. Since both solutions are absolutely the same I want to give both of them a credit.&lt;br /&gt;&lt;br /&gt;So to the point, ASP.NET AJAX framework has a class &lt;i&gt;Sys.Browser&lt;/i&gt; that represents a current browser and supports cross-browser compatibility for everything else. The solution simply extends the &lt;i&gt;Sys.Browser&lt;/i&gt; class to support a &lt;i&gt;Webkit&lt;/i&gt;browser:&lt;br /&gt;&lt;pre class="brush: javascript"&gt;&lt;br /&gt;Sys.Browser.WebKit = {};&lt;br /&gt;if( navigator.userAgent.indexOf('WebKit/') &gt; -1 )  {&lt;br /&gt;    Sys.Browser.agent = Sys.Browser.WebKit;&lt;br /&gt;    Sys.Browser.version = parseFloat(navigator.userAgent.match(/WebKit\/(\d+(\.\d+)?)/)[1]);&lt;br /&gt;    Sys.Browser.name = 'WebKit';&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;That is all the code you need. To apply this code to your web application you will need to create a javascript file, let's say &lt;i&gt;webkit.js&lt;/i&gt; and reference it in your application using standard &lt;i&gt;ScriptManager&lt;/i&gt; server control. You can reference the fix as a file using this syntax:&lt;br /&gt;&lt;pre class="brush: xhtml"&gt;&lt;br /&gt;&amp;lt;asp:ScriptManager ID="sm" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;Scripts&amp;gt;&lt;br /&gt;        &amp;lt;asp:ScriptReference Path="~/Scripts/webkit.js" /&amp;gt;&lt;br /&gt;    &amp;lt;/Scripts&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;or embed it into an assembly (my preferred way) and reference it from the assembly as an embedded resource:&lt;br /&gt;&lt;pre class="brush: xhtml"&gt;&lt;br /&gt;&amp;lt;asp:ScriptManager ID="sm" runat="server"&amp;gt;&lt;br /&gt;    &amp;lt;Scripts&amp;gt;&lt;br /&gt;        &amp;lt;asp:ScriptReference Assembly="Scripts" Name="Scripts.webkit.js" /&amp;gt;&lt;br /&gt;    &amp;lt;/Scripts&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Note that when you reference the fix from an assembly don't forget to add an assembly default namespace to the file name in the &lt;i&gt;Name&lt;/i&gt;attribute.&lt;br /&gt;&lt;br /&gt;In conclusion, according to my tests the fix eliminated problems with &lt;i&gt;UpdatePanel&lt;/i&gt;, &lt;i&gt;AjaxControlToolkit&lt;/i&gt;and &lt;i&gt;Virtual Earth&lt;/i&gt; map control.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-9173821638965454218?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/FDgla2ss-Fk" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-18T15:08:50.834-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">11</thr:total><feedburner:origLink>http://blog.turlov.com/2009/01/aspnet-ajax-compatibility-patch-for.html</feedburner:origLink></item><item><title>Search Engine Friendly Error Handling</title><link>http://feedproxy.google.com/~r/Webnet/~3/5NAlQg_2pjI/search-engine-friendly-error-handling.html</link><category>ASP.NET</category><category>SEO</category><category>best practice</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Fri, 20 Nov 2009 09:26:23 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-8527957612755063875</guid><description>ASP.NET provides a standard way to handle errors in web applications by configuring a &lt;b&gt;&lt;i&gt;customError&lt;/i&gt;&lt;/b&gt; section in the &lt;i&gt;Web.config&lt;/i&gt; file. Standard behaviour is to redirect a user from an erroneous page to an error page that in its turn shows some kind of more or less friendly explanation of what has happened.&lt;br /&gt;&lt;br /&gt;This approach is quite OK for intranet web applications but usually is not appropriate for a public web app accessible for search engines.&lt;br /&gt;&lt;br /&gt;The main problem here is that when error happens ASP.NET returns &lt;b&gt;302 "temporary redirect"&lt;/b&gt; response redirecting browser to the error page configured in the &lt;i&gt;Web.config&lt;/i&gt;.&lt;br /&gt;&lt;br /&gt;If the erroneous page was accessed by a SE bot the bot would index a content of the error handling page under the original page's URL thus creating a wrong index entry.&lt;br /&gt;&lt;br /&gt;Another problem is if the actual error on the page was that the requested content was not found. This scenario is quite regular on modern dynamic web sites that construct content pages dynamically based on a Url. In http world such a situation should be called as &lt;b&gt;404 "Not found"&lt;/b&gt; especially in the case of a bot visiting such a page. But ASP.NET standard handling will once again respond 302 and let the bot include a not existing page in a search index.&lt;br /&gt;&lt;br /&gt;What I am driving at is the correct error handling should always return a corresponding http status code for a SE bot with the appropriate content for the user. So how can we do that without writing too much code?&lt;br /&gt;&lt;br /&gt;Actually quite easy. Starting version 3.5 SP1 ASP.NET has a new attribute &lt;i&gt;redirectMode&lt;/i&gt; in the &lt;i&gt;customError&lt;/i&gt; configuration section:&lt;br /&gt;&lt;pre class="brush: xml"&gt;&lt;br /&gt;&lt;customerrors mode="RemoteOnly" defaultredirect="/errors/GenericError.aspx" redirectmode="ResponseRewrite"&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;The new &lt;i&gt;redirectMode&lt;/i&gt; attribute can be assigned one of two values: &lt;i&gt;ResponseRedirect&lt;/i&gt; (default) or &lt;i&gt;ResponseRewrite&lt;/i&gt;. ResponseRewrite prevents the erroneous page being redirected with the code 302 to an error page however the content of the error page will be shown on the original page. Internally ASP.NET is doing &lt;i&gt;Server.Execute&lt;/i&gt; of the error page instead of &lt;i&gt;Response.Redirect&lt;/i&gt; as usual.&lt;br /&gt;&lt;br /&gt;So this is already a one third of work. The next thing we need to do is to return a correct http status code. It can be achieved by adding a few lines of code to the error page let's say to a &lt;i&gt;Page_Load&lt;/i&gt; event handler:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;        int httpCode = 500;&lt;br /&gt;        Exception ex = Server.GetLastError();&lt;br /&gt;        if (ex is HttpException)&lt;br /&gt;        {&lt;br /&gt;            httpCode = ((HttpException) ex).GetHttpCode();&lt;br /&gt;        }&lt;br /&gt;        Response.StatusCode = httpCode;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;This code checks if the reason of the error was an &lt;i&gt;HttpException&lt;/i&gt; (a standard .NET exception class) then it assigns an http code from the exception otherwise it returns 500. Now it's two third of work done.&lt;br /&gt;&lt;br /&gt;What left is to handle exceptions in your code properly. The best practices here are:&lt;br /&gt;&lt;ul&gt;&lt;li&gt;If your application can not return a requested content for any reason except your application's internal problems then throw an &lt;i&gt;HttpException&lt;/i&gt; with the code 404 and it will be friendly handled by your error page.&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;    throw new HttpException(404, "Not found");&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Map other your application's specific exceptions to standard  http codes and return them too.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;If your application throws an exception internally then wrap the internal exception with &lt;i&gt;HttpException&lt;/i&gt; using an appropriate http code.&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;try&lt;br /&gt;{&lt;br /&gt;...&lt;br /&gt;}&lt;br /&gt;catch (Exception ex)&lt;br /&gt;{&lt;br /&gt;   throw new HttpException(code, message, ex);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;/li&gt;&lt;/ul&gt;That's basically it. In conclusion just a few more notes.&lt;br /&gt;&lt;br /&gt;If an erroneous page happened to start rendering content before the error occurred you may want to clear it on the error page before outputting an error message:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;    Response.Clear();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;If for some reason you can not use the new &lt;i&gt;redirectMode&lt;/i&gt; attribute in the &lt;i&gt;.config&lt;/i&gt; file (older framework, application specifics, etc.) then just add a few lines of code to the &lt;i&gt;global.asax&lt;/i&gt; that do the same:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;void Application_Error(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;    // Do something with the error, i.e. log, notify, etc. &lt;br /&gt;    Server.Transfer(errorpage);&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;It may be a good idea to clear an error status on the error page after you're done with error handling:&lt;br /&gt;&lt;pre class="brush: csharp"&gt;&lt;br /&gt;   ClearError();&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now that is all.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-8527957612755063875?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/5NAlQg_2pjI" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-11-20T12:26:23.020-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">7</thr:total><feedburner:origLink>http://blog.turlov.com/2009/01/search-engine-friendly-error-handling.html</feedburner:origLink></item><item><title>FIX: HTML documents may not be displayed correctly in IIS 7.0 on Windows Vista</title><link>http://feedproxy.google.com/~r/Webnet/~3/ubOkAJdVUsw/fix-html-documents-may-not-be-displayed.html</link><category>ASP.NET</category><category>IIS 7</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Tue, 09 Dec 2008 12:55:24 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-5584990657538398539</guid><description>Recently I have finally upgraded to Windows Vista from Windows &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_0"&gt;XP&lt;/span&gt;. Except regular trouble of upgrading your operation system that feels like moving to a new house (which is people say worse then an earthquake and flooding together) I was quite frustrated by a number of annoying problems with &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_1"&gt;IIS&lt;/span&gt; 7 when first it's not installed by default (all right, security is tougher now, but can I at least have an option?), then not all of the components installed that required by ASP.NET and VS2008 (is it so difficult to suggest a correct package?), then again my web app does not work with the default App Domain (why did you guys call it "default" and the real default call "&lt;span class="blsp-spelling-corrected" id="SPELLING_ERROR_2"&gt;classic&lt;/span&gt;"?), and finally everything works but the site does not look like it should be.&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I spent some time probing different setting of &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_3"&gt;IIS&lt;/span&gt; and finally gave up and looked it up on the Internet. What a relief! It's a Microsoft bug and not me being an idiot! Actually it was submitted on March 17, 2007 and still not in SP1.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;So the problem was that the entire static content of the web app including images and styles was not returning to a browser by &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_4"&gt;IIS&lt;/span&gt; (content length 0 bytes) because &lt;span class="blsp-spelling-error" id="SPELLING_ERROR_5"&gt;IIS&lt;/span&gt; 7 initial configuration was incorrect when it was first installed on Vista.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;I am not describing a fix here, read it here: &lt;a href="http://support.microsoft.com/kb/930901/en-us"&gt;http://support.microsoft.com/kb/930901/en-us&lt;/a&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-5584990657538398539?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/ubOkAJdVUsw" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2008-12-09T15:55:24.492-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2008/12/fix-html-documents-may-not-be-displayed.html</feedburner:origLink></item><item><title>Canada Election 2008</title><link>http://feedproxy.google.com/~r/Webnet/~3/bNFo1JqsiKs/canada-election-2008.html</link><category>Social</category><author>noreply@blogger.com (Alexander Turlov)</author><pubDate>Thu, 15 Jan 2009 11:13:52 PST</pubDate><guid isPermaLink="false">tag:blogger.com,1999:blog-602850767119300869.post-5830632392993910637</guid><description>&lt;p&gt;Once again - out of the main topic, but I can't be silent, can I?&lt;/p&gt;  &lt;p&gt;So I was straggling with myself over understanding what party should I vote for. The challenge was that it's not easy to figure out their election platforms. They do make a lot of noise but when it actually comes to statements there is somehow magically not so much to hear. Who are you talking to, guys? Can't you just drop your theatrical games and speak clearly of what you are about to do?&lt;/p&gt;  &lt;p&gt;Of course there are public images that could help making a choice: liberals are "thieves", conservatives are too easily "sold" to private interest groups, bloc are "nationalists", green are "blah" and NDP are "don't know who exactly". But still the statements are much easier to analyze for a thinking person.&lt;/p&gt;  &lt;p&gt;Luckily there is this very helpful &lt;a href="http://www3.thestar.com/static/election/quiz/index.html" target="_blank"&gt;web page called "Party Game"&lt;/a&gt; on thestar.com that shows the positions of all the parties on the main 8 problems. You take a quiz where you select your choice of a solution for each problem and at the end you see which party aligns the best with your own platform. Very helpful and surprising! Now I almost know who I will be voting for.&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/602850767119300869-5830632392993910637?l=blog.turlov.com' alt='' /&gt;&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/Webnet/~4/bNFo1JqsiKs" height="1" width="1"/&gt;</description><app:edited xmlns:app="http://www.w3.org/2007/app">2009-01-15T14:13:52.257-05:00</app:edited><thr:total xmlns:thr="http://purl.org/syndication/thread/1.0">0</thr:total><feedburner:origLink>http://blog.turlov.com/2008/10/canada-election-2008.html</feedburner:origLink></item></channel></rss>

