<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-2102007884459060816</id><updated>2024-09-13T04:26:55.117-07:00</updated><category term="Ajax"/><category term="Ajax Back Button"/><category term="Ajax History"/><category term="Distance"/><category term="Geocode"/><category term="History Remote plugin"/><category term="JSON"/><category term="Latitude"/><category term="Longitude"/><category term="RSH"/><category term="Really Simple History"/><category term="ScriptManager"/><category term="Sys.Res is undefined Sys.Net is undefined Sys.Application is undefined error ajax json"/><category term="UpdatePanel"/><category term="UpdatePanel performance"/><category term="Updatepanel safari"/><category term="Webservices"/><category term="jquery"/><category term="jquery bug"/><category term="name.replace is not a function"/><title type='text'>Web Programming , Design, Development, &amp;amp; Code Tutorials</title><subtitle type='html'>Windows and Web design, development, programming, code and tutorials. Let&#39;s swat those bugs!</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>24</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-964356968476454249</id><published>2015-07-26T20:08:00.001-07:00</published><updated>2015-07-26T20:08:58.394-07:00</updated><title type='text'>C# MetadataException: Unable to load the specified metadata resource error</title><content type='html'>This post will be about how to fix the &quot;MetadataException: Unable to load the specified metadata resource&quot; error in your ASP.NET web MVC and other applications. I&#39;ll keep this one short - what is going on is that the connection string that you used to setup the edmx for the entity model is different from the one now in your Web.Config file. How does it happen and what to do about it? Please see the below points -

&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;
&lt;li&gt;
Check to see if you recently changed connection strings for production deployment. This is actually the most common reason behind this problem.
&lt;/li&gt;
&lt;li&gt;
Check the entity names for csdl, ssdl and msl in the connection string in the Web.Config file. These appear right after the &quot;metadata=res://*/&quot; part of the connection string in the Web.Config file. 
&lt;/li&gt;
&lt;li&gt;
One thing to keep in mind (that also follows from the above points) is that the actual database name and connection infromation is most likely correct. I&#39;m saying this because when we think of connection strings, we tend to check only the database name and connection information. In this case it&#39;s the stuff that comes before the actual connection info (that is, before the &quot;provider...&quot; part of the string) that is likely to be messed up.
&lt;/li&gt;
&lt;li&gt;
Sometimes we copy paste the conenction strings between different applications. This is fine but remember that if you do it, then you must change the names of the csdl, ssdl and msl as well in addition to key and the actual connection info. Copying pasting connection strings between applications is another thing that usually causes this problem.
&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
&lt;br /&gt;
So bottomline, if you encounter the &quot;MetadataException: Unable to load the specified metadata resource&quot; error, then check each and every letter in your connection string and ensure that the parts at the beginning (the ones between &quot;metadata=//*/&quot; and &quot;provider&quot;) match with what was used to create the edmx entity model initially.</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/964356968476454249/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/c-metadataexception-unable-to-load_26.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/964356968476454249'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/964356968476454249'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/c-metadataexception-unable-to-load_26.html' title='C# MetadataException: Unable to load the specified metadata resource error'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-9054321247982684639</id><published>2015-07-24T23:16:00.000-07:00</published><updated>2015-07-24T23:16:40.163-07:00</updated><title type='text'>ASP.NET MVC Renders Length=4 in Html.ActionLink</title><content type='html'>You might have noticed this really strange behavior in ASP.NET MVC4 (and possibly other versions too) where @Html.ActionLink inexplicably appends the rendered links with &quot;?Length=4&quot;. For example, 
&lt;br /&gt;
&lt;br /&gt;
@Html.ActionLink(&quot;My App Header&quot;, &quot;Index&quot;, &quot;Home&quot;, new { //your html attributes })
&lt;br /&gt;
&lt;br /&gt;
becomes
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&quot;/MyApp/?Length=4&quot;&amp;gt;My App Header&amp;lt;/a&amp;gt;
&lt;br /&gt;
&lt;br /&gt;
This seems to make no sense at all, but there indeed is an explanation but before we get to that, let&#39;s first see a few ways of fixing it. 
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution 1 &lt;/b&gt; - Just add a null paramter after the Controller name parameter. Sp, change &lt;br /&gt;
&lt;br /&gt;
@Html.ActionLink(&quot;My App Header&quot;, &quot;Index&quot;, &quot;Home&quot;, new { //your html attributes }) to &lt;br /&gt;
&lt;br /&gt;
@Html.ActionLink(&quot;My App Header&quot;, &quot;Index&quot;, &quot;Home&quot;, &lt;u&gt;null&lt;/u&gt;, new { //your html attributes })
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution 2 &lt;/b&gt; - Use @Url.Action instead. So, basically change &lt;br /&gt;
&lt;br /&gt;
@Html.ActionLink(&quot;My App Header&quot;, &quot;Index&quot;, &quot;Home&quot;, new { //your html attributes }) to &lt;br /&gt;
&lt;br /&gt;
&amp;lt;a href=&quot;@Url.Action(&quot;Index&quot;, &quot;Home&quot;)&quot; //your html attributes&amp;gt;My App Header&amp;lt;/a&amp;gt;
&lt;br/&gt;&lt;br/&gt;
So, now with the solutions out of the way, here is the explanation for just where the Length=4 thing comes from - Basically the @Html.ActionLink method that your code runs in these cases is defined as follows -&lt;br/&gt;&lt;br/&gt;
public static string ActionLink(this HtmlHelper htmlHelper, string linkText, string actionName, object routeValues, object htmlAttributes) 
&lt;br/&gt;&lt;br/&gt; 
So, when ASP.NET MVC engine comes across a call like @Html.ActionLink(&quot;My App Header&quot;, &quot;Index&quot;, &quot;Home&quot;, new { //your html attributes }), it  takes &quot;Home&quot; as the routeValues parameter instead! The way routValues parameter works is that it looks for all public properties in the passed object and uses them for routing as per the routing configuratin. In the case of &quot;Home&quot; object, which is a string, the only public property is &quot;Length&quot; Now, since usually you don&#39;t have a &quot;Length&quot; route property in your configuration, it just appends the property name and value to querystring instead. Yes, the ASP.NET MVC Convention over Configuration at work here!! This is actually kinda cool when you think about it!! Now, as for why adding null in @Html.Action fixes it, it&#39;s because the null object doesn&#39;t have a public property (duh!). As a fun experiment, you could try adding another paramter to @Url.Action and you&#39;ll find the Length=4 querystring parameter in your rendered links again!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/9054321247982684639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-renders-length4-in.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/9054321247982684639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/9054321247982684639'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-renders-length4-in.html' title='ASP.NET MVC Renders Length=4 in Html.ActionLink'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-8108343520982088452</id><published>2015-07-24T20:10:00.003-07:00</published><updated>2015-07-24T20:10:43.805-07:00</updated><title type='text'>ASP.NET MVC Upload Large Files</title><content type='html'>I recently had to setup a website that required uploading huge files ranging from a few MBs to a few GBs. If you have come across this problem, you&#39;ll see that the control never reaches the Controller (pun not intended!) when uploading anything over 304 MB. Turns out ASP.NET requires the Web.Config file to be updated with the following -
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;b&gt;maxRequestLength attribute
&lt;/b&gt; - This attribute tells ASP.NET engine the maximum length of the request (duh!). This goes in the httpRuntime tag of your system.web file. The httpRuntime tag should already be present in your Web.Config, so just look it up and add the maxRequestLength attribute in there. For example - 
&lt;br /&gt;
&amp;lt;system.web&amp;gt;
    &lt;u&gt;&amp;lt;httpRuntime targetFramework=&quot;4.5&quot;  maxRequestLength=&quot;2147483647&quot;/&amp;gt;&lt;/u&gt;
&amp;lt;/system.web&amp;gt;
&lt;br /&gt;
It is set in KB and is set to 4096KB. . 
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;maxAllowedContentLength attribute
&lt;/b&gt; - This attribute tells ASP.NET engine the maximum content length (again duh!). This also goes in the Web.Config file, but in the requestLimits tag under requestFiltering under security tags in system.webServer. This might not be already present in your Web.Config file so just copy paste the below underlined code under the system.webServer tag -&lt;br /&gt;&lt;br /&gt;
&amp;lt;system.webServer&amp;gt;
&lt;u&gt;  &amp;lt;security&amp;gt;
      &amp;lt;requestFiltering&amp;gt;
        &amp;lt;requestLimits maxAllowedContentLength=&quot;2147483647&quot; /&amp;gt; 
      &amp;lt;/requestFiltering&amp;gt;
    &amp;lt;/security&amp;gt;&lt;/u&gt;
  &amp;lt;/system.webServer&amp;gt;
&lt;br /&gt;
It is set in Bytes. . 
&lt;/li&gt;
&lt;/ol&gt;
&lt;br /&gt;
And that&#39;s it. Now you can upload those huge files without any problems. A few things to note -
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;
The number in the maxRequestLength attribute is in KB (KiloBytes) but the number in the maxAllowedContentLength attribute is in Bytes.
&lt;/li&gt;
&lt;li&gt;
In cases when the sizes mentioned in maxRequestLength and maxAllowedContentLength attrbutes differ, ASP.NET engine will use the smaller one.
&lt;/li&gt;
&lt;li&gt;
The sizes are in unsigned integers, so they do have an upper limit.
&lt;/li&gt;
&lt;li&gt;
This is probably off topic but remember to not use functions like &quot;ReadToEnd()&quot; for reading files.
&lt;/li&gt;
&lt;/ol&gt;
</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/8108343520982088452/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-upload-large-files.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8108343520982088452'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8108343520982088452'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-upload-large-files.html' title='ASP.NET MVC Upload Large Files'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-9076332411488957558</id><published>2015-07-02T07:13:00.001-07:00</published><updated>2015-07-02T07:13:16.677-07:00</updated><title type='text'>ASP.NET MVC Form Submitting Twice Error</title><content type='html'>In this post I want to present the causes and resolutions of the cases when a form in a web application automatically submits more than once (usually twice). This usually happens with the forms created with @using (Ajax.BeginForm()) approach. A developer new to ASP.NET MVC can spend hours trying to find out the lines in their code that are duplicated resulting in duplicate form submissions. I have been there as well.
&lt;br/&gt;&lt;br/&gt;
So, what causes this error? It happens because &lt;b&gt;jquery.unobtrusive-ajax.js&lt;/b&gt; file is referenced more than once in the webpage. This could be as simple as the script tags being accidentally copied-pasted more than once in the page header or as complicated as a result of some idiosyncrasies of ASP.NET MVC Bundling features. Here are a few things that you can do to help locate and fix duplication.
&lt;br/&gt;&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;b&gt;Turn of Bundling optimizations&lt;/b&gt; - The first thing to debug it is to set BundleTable.EnableOptimizations = false in the RegisterBundles method of your BundleConfig.cs file in the App_Start folder. This will ensure that the individual script tags for all of the scripts are visible. 
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Remove the wildcards in ScriptBundle().Include()&lt;/b&gt; - Visual Studio usually creates some of the jQuery references using * wildcards. This can be found in the RegisterBundles method in the BundleConfig.cs file. Specifically, you&#39;re looking for the following line - &lt;br/&gt;
bundles.Add(new ScriptBundle(&quot;~/bundles/jqueryval&quot;).Include(&quot;~/Scripts/jquery.unobtrusive*&quot;));&lt;br/&gt;
Here jquery.unobtrusive* allows all of the unobtrusive files to be included in the project. But sometimes, if your script folder has both the regular (jquery.unobtrusive-ajax.js) and the minified (jquery.unobtrusive-ajax.min.js) versions of the file, essentially including the same file twice. Once you have isolated this as the cause, you can consider removing non-minified from the production server.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Check if any other views have the same Script.Render lines&lt;/b&gt; - Sometimes, visual studio will include the script sections in views by default for ASP.NET MVC projects, which can result in the developer accidentally copying the @Scripts.Render(&quot;~/bundles/jqueryval&quot;) line in more than one views. So, do a global search for the @Scripts.Render(&quot;~/bundles/jqueryval&quot;) line and remove it at all places except for the _Layout.cshtml / master page.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Check to ensure that jquery.unobtrusive-ajax.js file is included only once in the ScriptBundle&lt;/b&gt; - For this, you can do a seach for jquery-unobtrusive in the BundleConfig.cs file. If the same file or its minified versions appear more than once, then remove them.
&lt;/li&gt;
&lt;li&gt;&lt;b&gt;Turn off bundling and include the script tags in your page&lt;/b&gt; - If nothing else works, you can consider turning off the bundling. You can do this by removing the @Scripts.Render(&quot;~/bundles/jqueryval&quot;) line from your layout and all other views. Then add the script tags manually to only your layout or master page. This will help rule out the bundling issues. This will most likely fix this problem for good, as much as I like the bundling approach (Note: At the risk of being super cliche`, I should mention that it&#39;s not the bundling at fault here, it&#39;s how it&#39;s used in the application).
&lt;/li&gt;
&lt;/ol&gt;
</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/9076332411488957558/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-form-submitting-twice-error.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/9076332411488957558'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/9076332411488957558'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/aspnet-mvc-form-submitting-twice-error.html' title='ASP.NET MVC Form Submitting Twice Error'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-302421573523795041</id><published>2015-07-01T03:47:00.000-07:00</published><updated>2015-07-01T03:48:03.886-07:00</updated><title type='text'>How to fix &quot;$ is not a function&quot;,  &quot;$ or jQuery are not defined&quot; errors</title><content type='html'>In this post, I&#39;ll be explaining time tested remedies for the below erros commonly seen in ASP.NET MVC applications -
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;SyntaxError: missing } in compound statement&lt;/b&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;ReferenceError: jQuery is not defined&lt;/b&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;ReferenceError: $ is not defined&lt;/b&gt;
&lt;br/&gt;&lt;br/&gt;
&lt;b&gt;TypeError: $ is not a function&lt;/b&gt;
&lt;br/&gt;&lt;br/&gt;

You&#39;re likely to see these errors when deploying a new application or if you have made modifications to the BundleConfig.cs, _Layout.cshtml, master pages or other such files. I realize that the files that I listed are ASP.NET MVC specific, but the resolutions that I will be listing below apply to most technologies out there. BundleConfig.cs and _Layout.cshtml just refer to the places in ASP.NET MVC where we usually tell the ASP.NET MVC application where the scripts and styles are reside. 
&lt;br/&gt;&lt;br/&gt;
So, the error message &quot;jQuery is not defined&quot; clearly tells us that the jQuery script reference is missing. But when you you look in your scripts folder, it&#39;s there. The other errors don&#39;t even explain what could be wrong, but fear not, try out the below decetively simple resolutions and your errors should go away in a jiffy -
&lt;br/&gt;&lt;br/&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;b&gt;Check to ensure that the jquery file with the proper version is indeed present in your Scripts (or wherever you store the script files) folder&lt;/b&gt; - The jquery version part seems to cause these issues quite a bit, so ensure that the version referenced in your view/webpage is exactly the same as the version in the name of the file. In ASP.NET MVC world, you have the option to replace the version number with {version}, that is very helpful in avoiding this problem. So, your BundleConfig.cs will look like &lt;br/&gt;bundles.Add(new ScriptBundle(&quot;~/bundles/jquery&quot;).Include(&quot;~/Scripts/jquery-&lt;u&gt;{version}&lt;/u&gt;.js&quot;));
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Ensure that the script reference to your jquery file is indeed there in the rendered HTML page&lt;/b&gt; - This goes without saying but in an ASP.NET MVC application, sometimes the scripts will be bundled based on the setting of BundleTable.EnableOptimizations, which makes it almost impossible to see which scripts are actually referenced. Try setting BundleTable.EnableOptimizations to false to be able to see the script tags in the rendered page. I&#39;ll go further into the details of how to do it and where in the next item.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Check whether Bundle optimizations are on or off&lt;/b&gt; - Another commonly overlooked issue results from the default settings of the optimizations. Basically, ASP.NET MVC allows us to pick the minified versions and regular versions of script files based on this configuration setting. If you&#39;re not familiar with it, look for BundleTable.EnableOptimizations in the RegisterBundles method of your BundleConfig.cs file. If you see something like &lt;br/&gt; BundleTable.EnableOptimizations = true; &lt;br/&gt; then the application will be looking for the minified version of the scripts regardless of the name of the file in your BundleCollection. For example, if your jquery file is called, jquery-3.0.1.js and your BundleCollection line says ScriptBundle(&quot;~/bundles/jquery&quot;).Include(&quot;~/Scripts/jquery-&lt;u&gt;{version}&lt;/u&gt;.js&quot;)); and BundleTable.EnableOptimizations is set to true, then the app will be looking for jquery-3.0.1.&lt;u&gt;min&lt;/u&gt;.js and not the jquery-3.0.1.js file. The solution here is to just uploading the minified jquery-3.0.1.&lt;u&gt;min&lt;/u&gt;.js file. If you don&#39;t have the minified file, then you could set the BundleTable.EnableOptimizations to false and that would remedy it. A side benefit of setting the BundleTable.EnableOptimizations to false for testing is that then you&#39;d be able to see the script tags on the rendered HTML page for each of your scripts, as I mentioned in a previous point. On a side note, you&#39;d also want to check whether your Web.Config is set to debug or release mode.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Ensure that the jquery script reference occurs before any other script references in the webapge/view&lt;/b&gt; - This is another common problem when some other scripts that need jquery appear in your script reference section before the jquery file reference. These scripts look for jquery but the jquery file is not loaded because it&#39;s referenced further down the line. Just put the jquery reference on the top of your scripts section and you should be good.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Ensure that the jquery reference occurs before other references inside the BundleConfig.cs&lt;/b&gt; - The scripts added to the ASP.NET MVC ScriptsBundle render in the same order in which they appear in the BundleConfig.cs file. The remedy is simple, just put the ScriptBundle(&quot;~/bundles/jquery&quot;).Include(&quot;~/Scripts/jquery-&lt;u&gt;{version}&lt;/u&gt;.js&quot;)); line at the top of your RegisterBundles method.
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Check the file sizes of the jquery file on your deployment server&lt;/b&gt; - This one almost sounds silly but I&#39;ve seen cases when the file is not properly uploaded during deployment because of FTP errors etc. The way normal FTP works, if something breaks down during the STOR request in the middle of a big upload, at times the files being uploaded will stay on the server even though they were not fully uploaded. In other words, your file gets partially uploaded (or just an empty file is uploaded) when the upload request fails and now a cursory look will reveal that the file is there...but well, not really. If you don&#39;t have access to the production server, then it&#39;d help to look at the logs for any errors during uploads (yes, many of the FTP clients are set to keep going in case of errors).
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;Check the chaching mechanism of your app&lt;/b&gt; - Sometimes the app will cache bad files or sections of pages etc and no matter how many times you refresh, the problem won&#39;t go away. One less than ideal solution that I use is deleting the BundleCollection contents completely. You can do this by adding the following lines to the top of your RegisterBundles method in the BundleConfig.cs file (you wouldn&#39;t want to do it in the production code though) -&lt;br/&gt;
bundles.Clear(); bundles.ResetAll();
&lt;/li&gt;
&lt;/ol&gt;
&lt;br/&gt;&lt;br/&gt;
So, basically to summarize, we want to ensure that the name of the your jquery file matches exactly with the file name that shows up in the script tag in your view, masterpage, _layout.cshtml etc...and the size of the file matches and that the jquery reference script tag appears before all other scripts that you might be including. That&#39;s about it. In ASP.NET MVC world, there could be further complications because of the BundleConfig or WebConfig settings, but they&#39;re also easy to get around by a few small changes.
</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/302421573523795041/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/typeerror-is-not-function.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/302421573523795041'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/302421573523795041'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/07/typeerror-is-not-function.html' title='How to fix &quot;$ is not a function&quot;,  &quot;$ or jQuery are not defined&quot; errors'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-757102285571812790</id><published>2015-06-28T22:32:00.003-07:00</published><updated>2015-07-02T13:13:49.300-07:00</updated><title type='text'>ASP.NET MVC Create Editable Views for Collections</title><content type='html'>&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != &#39;function&#39;) {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
    prettyPrint();
});
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
/* Pretty printing styles. Used with prettify.js. */

.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
pre.prettyprint { padding: 2px; border: 1px solid #888; }

@media print {
  .str { color: #060; }
  .kwd { color: #006; font-weight: bold; }
  .com { color: #600; font-style: italic; }
  .typ { color: #404; font-weight: bold; }
  .lit { color: #044; }
  .pun { color: #440; }
  .pln { color: #000; }
  .tag { color: #006; font-weight: bold; }
  .atn { color: #404; }
  .atv { color: #060; }
}
&lt;/style&gt;
In this post, I want to focus on a few common mistakes when creating editable views for collections in ASP.NET MVC. These mistakes are related to the ASP.NET MVC wiere format and are pretty common and a new ASP.NET MVC programmer can spend hours trying to figure out what&#39;s wrong.
&lt;br /&gt;
&lt;br /&gt;
If you are new to ASP.NET MVC wire format, here is a quick primer - It is basically about how your model or viewmodel collection objects are rendered in the views. Let&#39;s say you have the following class -
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public class Person 
{
public int Id {get;set;}
public string Name {get;set;}
}
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Your Controller would look like -
&lt;br /&gt;
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public ActionResult PersonAction(Person[] employeeList) { ... }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Your View takes an IEnumerable of the Person class and looks like the below -
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
@model IEnumerable&amp;lt;Person&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, this Person collection/array &lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
Person employeeList[] = new Person[] {new Person() {Id=1, Name=&quot;person1&quot; }, new Person() {Id=2, Name=&quot;person2&quot;} }; 
&lt;/pre&gt;
&lt;br /&gt;
should show up as below in the rendered HTML -
&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
&amp;lt;input type=&#39;hidden&#39; value=&#39;0&#39; name=&#39;employeeList.Index&#39;/&amp;gt;
&lt;br /&gt;
&amp;lt;input type=&#39;text&#39; value=&#39;1&#39; name=&#39;employeeList[0].Id&#39; /&amp;gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&#39;text&#39; value=&#39;person1&#39; name=&#39;employeeList[0].Name&#39; /&amp;gt;
&lt;br /&gt;
&amp;lt;input type=&#39;hidden&#39; value=&#39;1&#39; name=&#39;employeeList.Index&#39;/&amp;gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;input type=&#39;text&#39; value=&#39;2&#39; name=&#39;employeeList[1].Id&#39; /&amp;gt;
&lt;br /&gt;
&amp;lt;input type=&#39;text&#39; value=&#39;person2&#39; name=&#39;employeeList[1].Name&#39; /&amp;gt;
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: This hidden index element is needed in case your list is unordered. For example, if your View supports deletion and addition of new collection items then the indexing can get out of order in a hurry. 
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;So, what are the most overlooked things that might save you hours of debugging? Here goes -&lt;/b&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ol&gt;
&lt;li&gt;&lt;b&gt;The &quot;name&quot; attribute of your HTML elements that render the collection properties must have the &lt;pre class=&quot;prettyprint lang-html&quot;&gt;ActionParameterName.PropertyName signature&lt;/pre&gt;&lt;/b&gt; -&lt;br /&gt; So, if your controller action method looks like &lt;br /&gt; &lt;pre class=&quot;prettyprint lang-html&quot;&gt;public ActionResult GetList(Person[] &lt;u&gt;employeeList&lt;/u&gt;)&lt;/pre&gt;&lt;br /&gt; and a property of the Person class is Id, then the name of the input elements must be like &lt;br /&gt; &lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;input type=&#39;text&#39; value=&#39;1&#39; name=&#39;&lt;u&gt;employeeList&lt;/u&gt;[0].&lt;u&gt;Id&lt;/u&gt;&#39; /&amp;gt;&lt;/pre&gt;&lt;br /&gt; (As in the the underlined parts). And it goes without saying that this naming convention will be used for all properties that are to be rendered.&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;The name of the hidden &quot;index&quot; element must have the ActionParameterName.Index signature&lt;/b&gt; - Again, if your controller action method looks like &lt;br /&gt; &lt;pre class=&quot;prettyprint lang-html&quot;&gt;public ActionResult GetList(Person[] &lt;u&gt;employeeList&lt;/u&gt;&lt;/pre&gt;)&lt;br /&gt; then the name of the hidden index element will be like &lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;input type=&#39;hidden&#39; value=&#39;0&#39; name=&amp;amp;#39&lt;u&gt;employeeList.Index&lt;/u&gt;&#39;/&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;b&gt;The index of all array elements must be same as the value of the hidden &quot;index&quot; element&lt;/b&gt; - So, for rendering the first element of the employeeList array (the index is zero), the hidden &quot;index&quot; element will look like &lt;br /&gt;&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;input type=&#39;hidden&#39; &lt;u&gt;value=&#39;0&#39;&lt;/u&gt; name=&#39;employeeList.Index&#39;/&amp;gt; &lt;/pre&gt;&lt;br /&gt; (notice the value is 0) and the element that render the property Id will look like &lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;&amp;lt;input type=&#39;text&#39; value=&#39;1&#39; name=&#39;&lt;u&gt;employeeList[0]&lt;/u&gt;.Id&#39; /&amp;gt;&lt;/pre&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;/ol&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/757102285571812790/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/aspnet-mvc-create-editable-views-for.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/757102285571812790'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/757102285571812790'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/aspnet-mvc-create-editable-views-for.html' title='ASP.NET MVC Create Editable Views for Collections'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-2334612388476144217</id><published>2015-06-23T01:16:00.004-07:00</published><updated>2015-06-23T05:54:07.911-07:00</updated><title type='text'>MVC4 Uncaught ReferenceError: $ is not defined</title><content type='html'>&quot;Uncaught ReferenceError: $ is not defined&quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a typical newbie error, specially when starting an ASP.NET MVC project. What&#39;s really going on is that the browser can&#39;t find the jquery file. But since &amp;nbsp;ASP.NET MVC automatically includes the javascript files as Script Bundles via the&amp;nbsp;@Scripts.Render(&quot;~/bundles/&lt;name bundle=&quot;&quot; of=&quot;&quot; the=&quot;&quot;&gt;&quot;), we don&#39;t know why the jquery script file is not included even though it is present under References.&amp;nbsp;&lt;/name&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Script.Render method basically allows automatic minification (compression) of javascripts and the Visual Studio IDE automatically adds some default bundles and placeholders for an ASP.NET MVC project.It&#39;s all nice and good but the problem is that the way ASP.NET MVC project is initially created, it makes it look like the references have already been added. The other equally confusing thing is the place ASP.NET MVC adds those script references by default. Unlike an ASP.NET Webforms application, the actual names of the javascript files don&#39;t appear in the aspx or cshtml files. So, they can&#39;t be found in the _Layout.cshtml or any other MVC *html file that is around.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
So, what do we do? We go to the BundleConfig.cs file in the App_Start folder. Over there there is a method (that has already been created by the ASP.NET MVC project) that contains all of the references to the actual javascript files.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The javascript registration code in BundleConfig.cs file will look something like this -&lt;br /&gt;
&lt;br /&gt;
bundles.Add(new ScriptBundle(&quot;~/bundles/jquery&quot;).Include(
&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;~/Scripts/jquery-{version}.js&quot;));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now the {version} part in the problematic part there. It doesn&#39;t seem to always work. Before I knew better, I thought it was a placeholder for us developers to fill in. But since the Visual Studio IDE doesn&#39;t give any indication how this can be fixed or even that something is wrong, a new developer trying to figure things out will never know what&#39;s going on.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
But fear not, the fix is simple. Simply change the file name to the actual jquery file name. It&#39;s not the ideal solution but will work in a pinch -&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
bundles.Add(new ScriptBundle(&quot;~/bundles/jquery&quot;).Include(&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &quot;~/Scripts/jquery-2.8.2.js&quot;));&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And add the following to your _Layout.cshtml -
@Scripts.Render(&quot;~/bundles/jquery&quot;)
&lt;br /&gt;
&lt;br /&gt;
And you are good to go! That&#39;s it. Now the script reference will show up in your browser as -
src=&quot;/Scripts/jquery-2.8.2.js&quot;
&lt;br /&gt;
&lt;br /&gt;
Another Victory! Now go have a beer!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/2334612388476144217/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/mvc4-uncaught-referenceerror-is-not.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/2334612388476144217'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/2334612388476144217'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/mvc4-uncaught-referenceerror-is-not.html' title='MVC4 Uncaught ReferenceError: $ is not defined'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-5800453174736243010</id><published>2015-06-20T07:34:00.000-07:00</published><updated>2015-07-02T13:19:39.144-07:00</updated><title type='text'>MVC4 - How to Bind Dropdowns lists and retain selected values during postbacks</title><content type='html'>&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot; src=&quot;http://google-code-prettify.googlecode.com/svn/trunk/src/lang-css.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != &#39;function&#39;) {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}
addLoadEvent(function() {
    prettyPrint();
});
&lt;/script&gt;
&lt;style type=&quot;text/css&quot;&gt;
/* Pretty printing styles. Used with prettify.js. */

.str { color: #080; }
.kwd { color: #008; }
.com { color: #800; }
.typ { color: #606; }
.lit { color: #066; }
.pun { color: #660; }
.pln { color: #000; }
.tag { color: #008; }
.atn { color: #606; }
.atv { color: #080; }
.dec { color: #606; }
pre.prettyprint { padding: 2px; border: 1px solid #888; }

@media print {
  .str { color: #060; }
  .kwd { color: #006; font-weight: bold; }
  .com { color: #600; font-style: italic; }
  .typ { color: #404; font-weight: bold; }
  .lit { color: #044; }
  .pun { color: #440; }
  .pln { color: #000; }
  .tag { color: #006; font-weight: bold; }
  .atn { color: #404; }
  .atv { color: #060; }
}
&lt;/style&gt;
I recently had a lot of trouble with dropdowns in MVC4. Either the dropdowns don&#39;t get populated, or they don&#39;t show the selected value, or they just don&#39;t postback the selected values. It&#39;s pretty straightforward to do these things in weakly typed Views but I wanted to make it all work with strongly typed Views because it results in a cleaner code in the long run.
&lt;br /&gt;
&lt;br /&gt;
So, without much ado, here is the code -
&lt;br /&gt;
&lt;br /&gt;
Your ViewModel (or Model depending on the architecture/approach) and helper classes look like the below -
&lt;br /&gt;
&lt;br /&gt;
//This class contains the keys, values and whatever other model related data that needs to be bound to the dropdown
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public class DropDownItem {
public int DropDownKey  { get; set; }
public string DropDownValue  { get; set; }
&lt;/pre&gt;
&lt;br /&gt;
&lt;br /&gt;
//This class is an overly simplified ViewModel 
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public class DropDownTestViewModel
    {
public DropDownSelectedValue { get; set; } //This represents the actual selected value
public IList&lt;dropdownitem&gt; DropDownItemCollection  = new List&lt;dropdownitem&gt;(); //This represents the list of all options in the dropdown
}
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
//This is the simplified View code -
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
@Html.DropDownListFor(imf =&amp;gt; Model.DropDownSelectedValue, new SelectList(Model.DropDownItemCollection.AsEnumerable(), &quot;DropDownKey&quot;, &quot;DropDownValye&quot;, Model.DropDownSelectedValue), &quot; -- Please Select --&quot;, new { id = &quot;ddl&quot; + rowCount })
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
The code looks pretty straightforward but the way MVC4 is designed, it&#39;ll never work. The dropdownlist will neither show the selected value nor post it back. And it will not tell you what is wrong either!! :)
&lt;br /&gt;&lt;br /&gt;
So, what is wrong here? After many iterations of writing and rewriting different variations of the code, I found that the problem is that the model items **MUST** be properties. So, to fix the above, we just need to add getters and setters as follows -
&lt;br /&gt;&lt;br /&gt;
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public IList&lt;dropdownitem&gt; DropDownItemCollection  = new List&lt;dropdownitem&gt;();
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
becomes this - 
&lt;pre class=&quot;prettyprint lang-html&quot;&gt;
public IList&lt;dropdownitem&gt; DropDownItemCollection   { get; set; } //Initialize in constructor etc as needed
&lt;/pre&gt;
&lt;br /&gt;&lt;br /&gt;
And hooray, the dropdown shows and posts back correct selected values and the world makes sense again. :)</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/5800453174736243010/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/mvc4-bind-dropdowns-selectedvalue.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5800453174736243010'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5800453174736243010'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2015/06/mvc4-bind-dropdowns-selectedvalue.html' title='MVC4 - How to Bind Dropdowns lists and retain selected values during postbacks'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-1853063683895776156</id><published>2011-03-01T21:14:00.000-08:00</published><updated>2011-03-05T08:09:15.465-08:00</updated><title type='text'>WordPress themes installation stuck at Unpacking Error</title><content type='html'>A lot of people get this strange error when wordpress seems to get stuck at the &quot;Unpacking the package step. This can happen with both automated admin installations and manual FTP theme uploads. This is a very frustrating error because  &quot;unpacking&quot; or unzipping the same theme files locally works just fine, it&#39;s just wordpress that doesn&#39;t seem to be able to handle them. This gets even more frustrating when we realize that wordpress is supposed to throw a timeout error after 30 seconds, but in this case it just freezes with no debugging messages whatsoever. &lt;br /&gt;
&lt;br /&gt;
Anyways, the reason it happens for in only a few select cases is because of the memory limitation imposted by the host, and as you can see, all we need to do is to increase the total amount of memory available to fix this. Below are the steps to fix it - &lt;br /&gt;
&lt;br /&gt;
Step 1: Connect to your wordpress FTP and drill down to wp-includes folder.&lt;br /&gt;
Step 2: Locate and open default-constants.php file in your favorite text editor.&lt;br /&gt;
Step 3: Look for the following term - WP_MEMORY_LIMIT (normally it&#39;s at line 23).&lt;br /&gt;
Step 4: Change define(&#39;WP_MEMORY_LIMIT&#39;, &#39;32M&#39;); to define(&#39;WP_MEMORY_LIMIT&#39;, &#39;64M&#39;);&lt;br /&gt;
&lt;br /&gt;
Please note that there will be more than one lines with the &quot;define(&#39;WP_MEMORY_LIMIT&#39;,...&quot; code and we&#39;re looking for the one that says 32M and not the one that already is set to 64M. &lt;br /&gt;
&lt;br /&gt;
Please also note that these settings are no longer available in the wp-settings.php file that is located in the wordpress root folder - Earlier this settings file indeed contained this code but since the last upgade, wp-settings.php calls the function wp_initial_constants() and that function is now located in default-constants.php file. It is this function that updates the WP_MEMORY_LIMIT variable depending on whether the wordpress site is multisite (via is_multisite() function) and this is what we change in the default-constants.php -&lt;br /&gt;
&lt;br /&gt;
Below are the before and after code snippets for your reference - &lt;br /&gt;
&lt;br /&gt;
BEFORE: &lt;br /&gt;
function wp_initial_constants( ) {&lt;br /&gt;
global $blog_id;&lt;br /&gt;
&lt;br /&gt;
// set memory limits&lt;br /&gt;
if ( !defined(&#39;WP_MEMORY_LIMIT&#39;) ) {&lt;br /&gt;
if( is_multisite() ) {&lt;br /&gt;
define(&#39;WP_MEMORY_LIMIT&#39;, &#39;64M&#39;);&lt;br /&gt;
} else {&lt;br /&gt;
define(&#39;WP_MEMORY_LIMIT&#39;, &#39;32M&#39;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
AFTER:&lt;br /&gt;
function wp_initial_constants( ) {&lt;br /&gt;
global $blog_id;&lt;br /&gt;
&lt;br /&gt;
// set memory limits&lt;br /&gt;
if ( !defined(&#39;WP_MEMORY_LIMIT&#39;) ) {&lt;br /&gt;
if( is_multisite() ) {&lt;br /&gt;
define(&#39;WP_MEMORY_LIMIT&#39;, &#39;64M&#39;);&lt;br /&gt;
} else {&lt;br /&gt;
define(&#39;WP_MEMORY_LIMIT&#39;, &#39;64M&#39;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Now, it should work but I&#39;ve also noticed that at times I&#39;ve to restart the webserver to get it going, this seems to be especially true when you&#39;ve a windows (as opposed to linux) hosting running on IIS 7. Also, just to avoid confusion - some hosting companies (including godaddy) refer to it as restarting or recycling application pools, implying they restart that particular process running your website (so to say) and not the entire webserver. It frees up any clogs and is the same thing as far as this issue is concerned.&lt;br /&gt;
&lt;br /&gt;
Hope this helps!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/1853063683895776156/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2011/03/wordpress-theme-unpackaging-stuck.html#comment-form' title='3 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/1853063683895776156'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/1853063683895776156'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2011/03/wordpress-theme-unpackaging-stuck.html' title='WordPress themes installation stuck at Unpacking Error'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>3</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-6996920445719464268</id><published>2010-03-10T11:37:00.000-08:00</published><updated>2010-06-07T06:18:30.729-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax Back Button"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax History"/><title type='text'>YUI Ajax Browser History Back Button Implementation</title><content type='html'>I&#39;ve been looking for some better solutions to the whole Ajax browser back button issue and I think I&#39;ve found the ideal candidate - YUI. For those who don&#39;t know much of this problem, I&#39;ll do a little recap. &lt;a href=&#39;#YUI&#39;&gt;If you already understand the problem, feel free to jump right to the YUI implementation&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Detailed theoretical explanation of the problem and solutions&lt;/b&gt; - basically, browser&#39;s back (and forward) button is meant to take the user to either the last page the user was on or the last location in the same page the user is currently at. Ajax updates though, just &quot;change&quot; a part of the page - in other words, they don&#39;t take the user to a new &quot;location&quot;. Consequently, since the location is still the same (only a part of the page changed, but addressbar still has the same location) browser doesn&#39;t register it as a &quot;change&quot; and the back button is never updated. So effectively, browser&#39;s back button doesn&#39;t work for the Ajax updates. This is a big problem since more and more websites are using Ajax updates for streamlined user interaction and without a functional back button, things like navigation menus and wizards become unusable.&lt;br /&gt;
&lt;br /&gt;
There is a nifty solution to this problem though - Since the browsers rely on the changes in location to make the back button functional, we can change the URL fragments and fool the browser into thinking that the page has changed. URL fragments are stuff that comes after &quot;#&quot; in the location and generally they represent internal links. So, by changing the URL fragments with each Ajax update, we can make the back button functional. But since the browsers see the changes in the URL fragments as internal links and not as Ajax updates, they still don&#39;t know exactly what changed! As far as the browsers are concerned, changes in URL fragments mean that the user just moved to a different part of the page but the contents of the page are exactly the same. Since they don&#39;t track what changed, they can&#39;t go back to what was before - meaning, clicking the back button doesn&#39;t take the user to the last state, it doesn&#39;t do anything. This means that we need to keep track of whenever the user clicks back and forward buttons. We can actually put the state information associated with the Ajax calls in the URL fragments and use it to update the page as back/forward buttons are clicked.&lt;br /&gt;
&lt;br /&gt;
But there is another problem - browsers don&#39;t expose any events for back/forward button clicks! So we can&#39;t tell when the user is going back or going forward and all that we can do is to poll and assume that the user clicked back/forward based on the current URL fragment. Further, we can use an iframe to store any data because an iframe won&#39;t be affected by navigation. This is basically the approach that is used by the popular browser history management solutions. Below is my experience with some of them -&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1) ASP.NET Ajax History&lt;/b&gt; - This is very easy to use and just requires setting the EnableHistory attribute of ScriptManager and implementing the Navigate event. The problem with this though is that ASP.NET posts the whole page back anyway (whole page is posted and received) - so if the viewstate is even moderately big, it can be very slow. This pretty much defeats part of the purpose of doing Ajax updates where we want to post only the essential data and receive only the updated parts of the page, to make it as quick as we can. This is also the problem with ASP.NET&#39;s whole Ajax management system.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2) Really Simple History (RSH)&lt;/b&gt; - I&#39;ve used with ASP.NET Ajax history and as a sole history management solution....and it works.....more or less. The problem is that its somehow hard to get right at the very first attempt. As you&#39;d see in the comments &lt;a href=&#39;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&#39; title=&#39;how to implement RSH&#39;&gt;here&lt;/a&gt;, pretty much every one had problems trying to set it up. But that&#39;s not really a &#39;problem&#39;, per say. The problem is that it hasn&#39;t worked for me in some versions of Internet Explorer (IE) and as we all know, IE is the most popular browser out there. It could just be my implementation but the way I look at it - it&#39;s just a means to an end, if something else exists that can solve the same problem with less effort then just use that other thing.....&lt;br /&gt;
&lt;br /&gt;
Which brings us to....&lt;br /&gt;
&lt;a name=&quot;YUI&quot;&gt;&lt;/a&gt;&lt;br /&gt;
&lt;b&gt;3) YUI Browser History Manager&lt;/b&gt; - I very recently tried to implement it and I was suprised that it &quot;just worked&quot; in the very first try and without any problems....or may be I&#39;ve just got smarter...whatever the case may be, I&#39;ve successfully used it for many of my projects now and would recommend it. Below is some information on how to implement it -&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Implementing YUI Browser History Manager:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 1:&lt;/b&gt; Download the following javascript files and include them:&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; (jquery needed for YUI)&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/yahoo-dom-event.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/connection.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/history.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt; (from YUI - http://developer.yahoo.com/yui/history/)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 2:&lt;/b&gt; Add the below code right after the body tag&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&amp;lt;iframe id=&amp;quot;yui-history-iframe&amp;quot; src=&amp;quot;assets/blank.html&amp;quot; width=&amp;quot;1px&amp;quot; height=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;input id=&amp;quot;yui-history-field&amp;quot; type=&amp;quot;hidden&amp;quot; /&amp;gt;&lt;/span&gt;&lt;br /&gt;
(Note: iframe is needed only for IE)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 3:&lt;/b&gt; Add the below code right before the end of the body tag (or wherever you put your javascript)&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
var bookmarked = YAHOO.util.History.getBookmarkedState(&amp;quot;state&amp;quot;);&lt;br /&gt;
var init = bookmarked || query || &amp;quot;page1.aspx&amp;quot;;&lt;br /&gt;
YAHOO.util.History.register(&amp;quot;state&amp;quot;, init, OnStateChanged);&lt;br /&gt;
try {&lt;br /&gt;
YAHOO.util.History.initialize(&amp;quot;yui-history-field&amp;quot;, &amp;quot;yui-history-iframe&amp;quot;);&lt;br /&gt;
} catch (e) {&lt;br /&gt;
}&lt;br /&gt;
YAHOO.util.History.onReady(function () {});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Now, if all you care about are back/forward buttons for one set of Ajax calls, then you don&#39;t need to change anything in the above code. But if you also want page refreshes and bookmarking support, then some more code will go into the onReady method above (I&#39;ll be writing another post for bookmarking support).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Step 4:&lt;/b&gt; Add the below code to all your Ajax calls. &lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;YAHOO.util.History.navigate(&quot;state&quot;, param);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Note the &quot;param&quot; argument above - this is where you store the state information that you&#39;ll be using when back/forward buttons are clicked. Below is a sample code:&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;
//Ajax call that needs browser&#39;s back button to work&lt;br /&gt;
function AjaxShowAppleImage()&lt;br /&gt;
{&lt;br /&gt;
// Ajax code that shows an apple&#39;s image&lt;br /&gt;
$(&#39;#img1&#39;).attr(&#39;src&#39;, &#39;apple.jpg&#39;);&lt;br /&gt;
//YUI code&lt;br /&gt;
YAHOO.util.History.navigate(&quot;state&quot;, &#39;apple&#39;);&lt;br /&gt;
}&lt;br /&gt;
//Another ajax call that needs browser&#39;s back button to work&lt;br /&gt;
function AjaxShowOrangeImage()&lt;br /&gt;
{&lt;br /&gt;
// Ajax code that shows an apple&#39;s image&lt;br /&gt;
$(&#39;#img1&#39;).attr(&#39;src&#39;, &#39;orange.jpg&#39;);&lt;br /&gt;
//YUI code&lt;br /&gt;
YAHOO.util.History.navigate(&quot;state&quot;, &#39;orange&#39;);&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;b&gt;Step 5:&lt;/b&gt; Implement a OnStateChanged function. This OnStateChanged is called whenever the back/forward buttons are clicked and you use the &quot;state&quot; parameter (from above) to update the page (in our example - show the correct fruit image). Below is a sample explanation -&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;
function OnStateChanged(state)&lt;br /&gt;
{&lt;br /&gt;
if(state == &#39;apple&#39;)&lt;br /&gt;
$(&#39;#img1&#39;).attr(&#39;src&#39;, &#39;apple.jpg&#39;);&lt;br /&gt;
else if(state == &#39;orange&#39;)&lt;br /&gt;
$(&#39;#img1&#39;).attr(&#39;src&#39;, &#39;orange.jpg&#39;);&lt;br /&gt;
}&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
And that&#39;s all you need to do. Pretty simple, isn&#39;t it?&lt;br /&gt;
&lt;br /&gt;
This ends this post. For those who would like to grab some working code as a starting point, you can take the below code. It has been tested on most popular browsers and works perfectly. It basically contains a couple of links that load the content from two pages (page1.aspx and page2.aspx). It assumes that both these pages have a div with the id as &quot;content&quot; and loads their content in a div with an id &quot;loadedContent&quot;. Have fun ajaxing! :)&lt;br /&gt;
&lt;br /&gt;
(UPDATE 06-07-2010: Fixed a minor bug related to missing comma in the YAHOO.util.History.register method after &quot;init&quot; in the below code - YAHOO.util.History.register(&amp;quot;state&amp;quot;, init, function(state)... - Thanks to Mike in the comments for pointing it out)&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;
&amp;lt;iframe id=&amp;quot;yui-history-iframe&amp;quot; src=&amp;quot;assets/blank.html&amp;quot; width=&amp;quot;1px&amp;quot; height=&amp;quot;1px&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/iframe&amp;gt;&lt;br /&gt;
&amp;lt;input id=&amp;quot;yui-history-field&amp;quot; type=&amp;quot;hidden&amp;quot; /&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/jquery.min.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/yahoo-dom-event.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/connection.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot; src=&amp;quot;/history.js&amp;quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;a href=&amp;quot;page1.aspx&amp;quot; onclick=&amp;quot;$(&#39;#loadedContent&#39;).load(&#39;page1.aspx #content&#39;);YAHOO.util.History.navigate(&#39;state&#39;, &#39;page1.aspx&#39;);return false;&amp;quot;&amp;gt;&lt;br /&gt;
page1&amp;lt;/a&amp;gt; &amp;lt;a href=&amp;quot;page2.aspx&amp;quot; onclick=&amp;quot;$(&#39;#loadedContent&#39;).load(&#39;page2.aspx #content&#39;);YAHOO.util.History.navigate(&#39;state&#39;,&#39;page2.aspx&#39;);return false;&amp;quot;&amp;gt;&lt;br /&gt;
page2&amp;lt;/a&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;div id=&amp;quot;loadedContent&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&amp;lt;/form&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;script type=&amp;quot;text/javascript&amp;quot;&amp;gt;&lt;br /&gt;
var bookmarked = YAHOO.util.History.getBookmarkedState(&amp;quot;state&amp;quot;);&lt;br /&gt;
var query = YAHOO.util.History.getQueryStringParameter(&amp;quot;divs&amp;quot;);&lt;br /&gt;
var init = bookmarked || query || &amp;quot;page1.aspx&amp;quot;;&lt;br /&gt;
YAHOO.util.History.register(&amp;quot;state&amp;quot;, init, function(state) {$(&#39;#loadedContent&#39;).load(state + &#39; #content&#39;);});&lt;br /&gt;
try {&lt;br /&gt;
YAHOO.util.History.initialize(&amp;quot;yui-history-field&amp;quot;, &amp;quot;yui-history-iframe&amp;quot;);&lt;br /&gt;
} catch (e) {&lt;br /&gt;
}&lt;br /&gt;
YAHOO.util.History.onReady(function () {});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/6996920445719464268/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/yui-ajax-browser-history-back-button.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6996920445719464268'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6996920445719464268'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/yui-ajax-browser-history-back-button.html' title='YUI Ajax Browser History Back Button Implementation'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-3106369308693319635</id><published>2010-03-10T10:23:00.001-08:00</published><updated>2010-03-10T11:07:58.239-08:00</updated><title type='text'>Windows Vista resets user profile/account settings issue</title><content type='html'>I&#39;ve been having this strange problem - Windows Vista resets my profile (user account) to factory settings. This means all my installed programs, settings, desktop, documents simply disappear! The problem seems to happen seemingly randomly whenever I restart my system and I suspect that windows creates a backup of the user profile to install some updates or something and never restores that backed up profile. This means that the documents and settings are still there its just the registry settings, that store the profile information, have got messed up. Below is the solution in case any of you guys encounter this problem -&lt;br /&gt;&lt;br /&gt;1. Go to your registry (Start -&gt; Run -&gt; regedit)&lt;br /&gt;&lt;br /&gt;2. You will see a treeview on the left side. Expand the following nodes - HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList&lt;br /&gt;&lt;br /&gt;3. Under ProfileList you should see a list of keys with names like S-1-5-18 and S-1-5-21-516313125-3752655690-3918728212-1000 etc. These are the keys that contain your profile information. Below is a screenshot from my registry -&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-cr7lvILbSSCRg8hAmMyBXlIQMjStakdFe89GOaQAflB7xaVosFBnZEV8-YtPDe51UIV7akOj2-5XnR2brEdYNWdP4JWefkf7cLP3irDUvFSnen4uqm0JH7O6TVplnQxizQCBPCuSINw/s1600-h/vista-resets-account-settings-registry.JPG&quot; title=&quot;vista-resets-account-settings-registry&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 182px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-cr7lvILbSSCRg8hAmMyBXlIQMjStakdFe89GOaQAflB7xaVosFBnZEV8-YtPDe51UIV7akOj2-5XnR2brEdYNWdP4JWefkf7cLP3irDUvFSnen4uqm0JH7O6TVplnQxizQCBPCuSINw/s400/vista-resets-account-settings-registry.JPG&quot; border=&quot;0&quot; alt=&quot;vista-resets-account-settings-registry&quot;id=&quot;BLOGGER_PHOTO_ID_5447083463970288514&quot; /&gt;&lt;/a&gt;&lt;br /&gt;4. Look for a key that has &quot;.bak&quot; at the end of its name. This should be your original profile. Make sure that the ProfileImagePath on the right hand side is pointing to &quot;C:\Users\[your computer name]&quot;. Below is a screenshot of how the whole thing looks on my system -&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gJ2Ymh9OrnAOqAS_Re0z8KMirdq_gbO0ONRnb8NcE9pQlkhY20z-AI5AtrwUSx9yQzUti-Vrahp0JJOjX5XSNGpkDk5R7GHJ2cTXkYaiM_eS_XRxv7Dr-DwNNfU4OhhebS3ewNV0g38/s1600-h/vista-resets-account-settings-registry2.JPG&quot; title=&quot;vista-resets-account-settings-registry&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 219px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg7gJ2Ymh9OrnAOqAS_Re0z8KMirdq_gbO0ONRnb8NcE9pQlkhY20z-AI5AtrwUSx9yQzUti-Vrahp0JJOjX5XSNGpkDk5R7GHJ2cTXkYaiM_eS_XRxv7Dr-DwNNfU4OhhebS3ewNV0g38/s400/vista-resets-account-settings-registry2.JPG&quot; border=&quot;0&quot; alt=&quot;vista-resets-account-settings-registry&quot;id=&quot;BLOGGER_PHOTO_ID_5447083907006440754&quot; /&gt;&lt;/a&gt;&lt;br /&gt;5. Look for another key with the same name but without &quot;.bak&quot; at the end of its name. This is a temporary profile, you&#39;d notice that the ProfileImagePath on the right hand side is pointing to &quot;C:\Users\TEMP.[your computer name]&quot;. Below is a screenshot of how the whole thing looks on my system -&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGKdo0Xunm0p47O8YMBKFRIGpb2toEUrT9MUonmH39F2bgVwV8uXYFXgcvTGrStujY_FJFHOCf4TJe_mXetsrA-CBn9ilgAZ2Y3SsgEcNSyeNJfn5Zj4-tCWCwAD0Qpo8trK2H_mmW1_w/s1600-h/Capture.JPG&quot;&gt;&lt;img style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 289px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjGKdo0Xunm0p47O8YMBKFRIGpb2toEUrT9MUonmH39F2bgVwV8uXYFXgcvTGrStujY_FJFHOCf4TJe_mXetsrA-CBn9ilgAZ2Y3SsgEcNSyeNJfn5Zj4-tCWCwAD0Qpo8trK2H_mmW1_w/s400/Capture.JPG&quot; border=&quot;0&quot; alt=&quot;vista-resets-account-registry&quot;id=&quot;BLOGGER_PHOTO_ID_5447082618538191250&quot; /&gt;&lt;/a&gt;&lt;br /&gt;6. Rename the temp key (from step 5) to &quot;.bak1&quot; or something and rename actual key (from step 4) to what the temp key was (i.e., remove the &quot;.bak&quot; part)&lt;br /&gt;&lt;br /&gt;7. Restart and you should get all your documents/settings/programs back. &lt;br /&gt;&lt;br /&gt;(Note: If the problem persists, then undo the changes and contact the system admin. Also, as a disclaimer, I don&#39;t represent Microsoft and my advice is as-is)</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/3106369308693319635/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/vista-resets-profile-account.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/3106369308693319635'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/3106369308693319635'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/vista-resets-profile-account.html' title='Windows Vista resets user profile/account settings issue'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-cr7lvILbSSCRg8hAmMyBXlIQMjStakdFe89GOaQAflB7xaVosFBnZEV8-YtPDe51UIV7akOj2-5XnR2brEdYNWdP4JWefkf7cLP3irDUvFSnen4uqm0JH7O6TVplnQxizQCBPCuSINw/s72-c/vista-resets-account-settings-registry.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-5363681455041028453</id><published>2010-03-03T12:15:00.001-08:00</published><updated>2010-03-03T13:59:46.219-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Distance"/><category scheme="http://www.blogger.com/atom/ns#" term="Geocode"/><category scheme="http://www.blogger.com/atom/ns#" term="Latitude"/><category scheme="http://www.blogger.com/atom/ns#" term="Longitude"/><title type='text'>How to geocode and find distance between two addresses using ASP.NET</title><content type='html'>Many websites these days allow the users to find location based points of interests. Examples would be a website that provides a list of schools in your zipcode or restaurants x miles from your address (or current location). Further, the user is allowed to sort or group the points of interests by proximity and so on. In this article, I&#39;ll provide step by step process of implementing geocoding and finding distances between two points on a map.&lt;br /&gt;&lt;br /&gt;Now, as you see, there is no real way to calculate actual distances solely by zipcodes and addresses. We need to be able to figure out the coordinates (Latitudes and Longitudes) for those zipcodes and addresses. This &lt;span style=&quot;font-weight:bold;&quot;&gt;process of finding Latitude/Longitude for a location is called geocoding&lt;/span&gt;. Once we have the Latitudes and Longitudes, we can use the &lt;span style=&quot;font-weight:bold;&quot;&gt;Haversine formula to figure out the actual distance&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Step1: How to Geocode a Zipcode (convert a zipcode into latitude &amp;amp; longitude)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The easiest way to do it by simply getting this data from US census website - http://www.census.gov/geo/www/gazetteer/places2k.html . The file of interest is &quot;ZCTAs (ZIP Code Tabulation Areas)&quot;. Below is a sample code that can parse this file:&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;TextReader tr = File.OpenText(@&quot;C:\zcta5.txt&quot;);&lt;br /&gt;while ((line = tr.ReadLine()) != null)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string zip = line.Substring(2, 5);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string latitude = line.Substring(&lt;b&gt;136, 10&lt;/b&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string longitude = line.Substring(&lt;b&gt;146, 11&lt;/b&gt;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Code to save this to database&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Note: It would be faster to bulkload this file instead of parsing it line by line, the above code is just for reference.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Step2: How to geocode an address?&lt;/span&gt; This is important because we&#39;d like to geocode the actual addresses provided by the user. For example, the user might provide his/her address looking for restaurants within 5 miles of the address. This is also necessary for any non-US zipcodes (or postal codes) or a list of addresses that you might be working with (for example, you might have a list of school&#39;s addresses and your website might let the users find schools within 50 miles of a zipcode).&lt;br /&gt;&lt;br /&gt;To geocode such addresses we will use Google Maps API&#39;s geocoding service. This is basically a RESTful webservice that takes the address and other parameters and returns the Latitudes and Longitudes for the same. A sample uri would look like - http://maps.google.com/maps/geo?q=[your-address]&amp;amp;output=csv&amp;amp;key=[your-key]. You&#39;ll have to sign up at http://code.google.com/apis/maps/signup.html to obtain the &quot;key&quot; parameter. Once you have the key, you can run all your addresses through this and obtain the coordinates. Sample C# code is below:&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;foreach(var address in AddressList)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Uri uri = new Uri(&quot;http://maps.google.com/maps/geo?q=&quot; +         &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;System.Web.HttpUtility.UrlEncode(address) + &quot;&amp;amp;output=csv&amp;amp;key=[your key]&quot;);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;WebClient webClient = new WebClient();&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string[] geoCodedAddress = webClient.DownloadString(uri).Split(&#39;,&#39;);&lt;br /&gt;&lt;b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string latitude = geoCodedAddress[2];&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;string longitude = geoCodedAddress[3];&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;//Save the extracted coordinates&lt;br /&gt;}&lt;/span&gt;&lt;br /&gt;Note: If you are running a console application then System.Web won&#39;t seem to expose the HttpUtility class. The solution is to add a reference to System.Web.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight:bold;&quot;&gt;Step 3: How to calculate distance between two coordinates (two sets of latitudes and longitudes)?&lt;/span&gt; Since earth is spherical (well not exactly), we use what is known as Haversine formula to calculate the distance. The reason being, the distance here is a curve along the surface of earth as opposed to being a straight line between two points. I won&#39;t go into the actual formula here though, below is the sample C# code that implements it:&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;public double GetDistance(Coordinate location1, Coordinate location2)&lt;br /&gt; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double diffLat = Math.PI / 180 * Convert.ToDouble((location1.Latitude - location2.Latitude));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;double diffLon = Math.PI / 180 * Convert.ToDouble((location1.Longitude - location2.Longitude));&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;return 3960 * 2 * Math.Asin(Math.Min(1, Math.Sqrt(&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Math.Sin(diffLat / 2) * Math.Sin(diffLat / 2) +&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Math.Cos(Math.PI / 180 *       Convert.ToDouble(location1.Latitude)) * &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Math.Cos(Math.PI / 180 *       Convert.ToDouble(location2.Latitude)) *&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Math.Sin(diffLon / 2) * Math.Sin(diffLon / 2))));&lt;br /&gt; }&lt;/span&gt;&lt;br /&gt;Note: Coordinate is just a struct with Latitude and Longitude as exposed properties. The conversions to double can be removed as well as needed.&lt;br /&gt;&lt;br /&gt;In conclusion, we covered the extracting geocoded zipcodes from census database, geocoding any random addresses using google map&#39;s API and finally Haversine formula for calculating the actual distance between two geocoded locations (distance between Latitudes and Longitudes). This should allow us to find distance between any set of locations given the full or partial addresses or zipcodes.</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/5363681455041028453/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/geocode-address-distance-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5363681455041028453'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5363681455041028453'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2010/03/geocode-address-distance-aspnet.html' title='How to geocode and find distance between two addresses using ASP.NET'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-6037193635273014556</id><published>2009-01-28T09:56:00.001-08:00</published><updated>2009-01-28T15:24:13.184-08:00</updated><title type='text'>SQL Server Management Studio not installed with Sql Server 2005 Installation</title><content type='html'>I came across this problem when trying to install Sql Server Management Studio and other client tools. Basically, &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;for many different reasons, Management Studio and other client tools will not install after you&#39;ve installed SQL Server 2005&lt;/span&gt; server components. The error that is thrown is below -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;Name: Microsoft SQL Server 2005 Tools Express EditionReason:&lt;span style=&quot;font-weight:bold;&quot;&gt; Your upgrade is blocked.&lt;/span&gt; For more information about upgrade support, see the &quot;Version and Edition Upgrades&quot; and &quot;Hardware and Software Requirements&quot; topics in SQL Server 2005 Setup Help or SQL Server 2005 Books Online.&lt;br /&gt;Build version check:&lt;br /&gt;Your upgrade is blocked because the existing component is a later version than the version you are trying to upgrade to. To modify an existing SQL Server component, go to Add or Remove Programs in Control Panel, select the component you would like to modify, and then click Change/Remove.&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;A screen shot of this problem is here:&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUezUhfVTNmOi8grHNMCCKaWmQ-rdy2CCDMtkxJIX3HcEm_ZdgyRjlD8mrsrzhqiks93rAdXhGftlot5OhinWUy6K6k3ubOgZA0O6xI8TXb4ChfO0gVtTYIUSHsAf6J5kxBKM3Cz5TdEA/s400/sql-server-2005-management-studio-installation3.jpg&quot; title=&quot;SQL Server 2005 Management Studio Installation upgrade is blocked&quot;&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUezUhfVTNmOi8grHNMCCKaWmQ-rdy2CCDMtkxJIX3HcEm_ZdgyRjlD8mrsrzhqiks93rAdXhGftlot5OhinWUy6K6k3ubOgZA0O6xI8TXb4ChfO0gVtTYIUSHsAf6J5kxBKM3Cz5TdEA/s400/sql-server-2005-management-studio-installation3.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 361px;&quot; border=&quot;0&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5296455406964269410&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The problem here is basically that &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;SQL Server 2005 installer seems to think that a higher version or something of SQL Server is already installed&lt;/span&gt; on this machine and therefore blocks the current installation by disabling the checkbox that could&#39;ve made all our lives much easier.&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg676DYjoLssFlCM91rpl0l_kmtAPyywoSeoW2DMrPSaHb64ibLg-cLEjOgCXFzteDOq7yy1CKUiWlpyOg5LKXlRHXu5oyjevGcj7Az1LULwjwVMHodCtxJiGQ48luuOB8XRMaEcLSbOiw/s400/sql-server-2005-management-studio-installation4a.jpg&quot; title=&quot;SQL Server 2005 Management Studio Installation upgrade is blocked&quot;&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg676DYjoLssFlCM91rpl0l_kmtAPyywoSeoW2DMrPSaHb64ibLg-cLEjOgCXFzteDOq7yy1CKUiWlpyOg5LKXlRHXu5oyjevGcj7Az1LULwjwVMHodCtxJiGQ48luuOB8XRMaEcLSbOiw/s400/sql-server-2005-management-studio-installation4a.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 364px;&quot; border=&quot;0&quot; alt=&quot;sql-server-2005-management-studio-installation&quot; id=&quot;BLOGGER_PHOTO_ID_5296456772078999378&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As the obvious rectification step, I tried to find that missing prior installation of SQL Server but as expected, it was nowhere to be found and also for some reason &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;this problem can&#39;t always be rectified by reinstalling SQL Server&lt;/span&gt;. So, we can&#39;t uninstall the previous version that SQL Server installer thinks is already there and we are stuck. So what gives? It turns out that &lt;span class=&quot;Apple-style-span&quot; style=&quot;font-weight: bold;&quot;&gt;we can set SKUUPGRADE to 1 while installing from the command prompt - E:\&gt;setup.exe SKUUPGRADE=1&lt;/span&gt; - This enables that silly checkbox to allow installation (or upgradation) of the client components. Below is how this command prompt looks on my system for reference -&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpwCDtd5VN48YOUQQzjrRYaKwkao-bsCAcHGujoQaQTAyhs-foIUKWdXDUZwIDZb427c3XZmdRp7X3qEDJsybrQjXETo7CR8bYcBuG6_o_mdPmxXVyRp7P3z3OogSj30jGoZdnNfEqWRA/s400/sql-server-2005-management-studio-installation5.jpg&quot; title=&quot;SQL Server 2005 Management Studio Installation upgrade is blocked&quot;&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjpwCDtd5VN48YOUQQzjrRYaKwkao-bsCAcHGujoQaQTAyhs-foIUKWdXDUZwIDZb427c3XZmdRp7X3qEDJsybrQjXETo7CR8bYcBuG6_o_mdPmxXVyRp7P3z3OogSj30jGoZdnNfEqWRA/s400/sql-server-2005-management-studio-installation5.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 133px;&quot; border=&quot;0&quot; alt=&quot;sql-server-2005-management-studio-installation&quot; id=&quot;BLOGGER_PHOTO_ID_5296459590963742546&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once you run the installer with SKUUPGRADE ON, you should be able to see the option to install SQL Server Management Studio in the installer. Below is a screen shot that shows how it looks now (please ignore the Integration Service thing as that&#39;s disabled in the picture for an entirely different reason) -&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi_OnhL7UJ2f_RGDto88MQxx5d_jvGZ0XP2rW_yjcpIdKXAkAQ_d_aJOHoPMesQ7OkEoa70uPLCLexZJ_9VGCCgoaGfN19ZYWpdLZuJ5ewd5YBCoh5c13oFUOu0vxucwpuWmS_Hzzb_Fs/s400/sql-server-2005-management-studio-installation6.jpg&quot; title=&quot;SQL Server 2005 Management Studio Installation upgrade is blocked&quot;&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgi_OnhL7UJ2f_RGDto88MQxx5d_jvGZ0XP2rW_yjcpIdKXAkAQ_d_aJOHoPMesQ7OkEoa70uPLCLexZJ_9VGCCgoaGfN19ZYWpdLZuJ5ewd5YBCoh5c13oFUOu0vxucwpuWmS_Hzzb_Fs/s400/sql-server-2005-management-studio-installation6.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 368px;&quot; border=&quot;0&quot; alt=&quot;sql-server-2005-management-studio-installation&quot; id=&quot;BLOGGER_PHOTO_ID_5296460249838604866&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now when you click Next, you should see the below -&lt;br /&gt;&lt;br /&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc5N4LtxS_zvfHpBZD9FKGOv_Sls90p1jr9hmS-O9eSKawp1Uv9Tl07W-pR7i4hh7t3DVE2pojn5eVwepvqJlgXAtTlPz9z_yZDy1_DtqeUAe0sNLogzMBrQSe4EPGDvM4TRxrvcyY7E4/s400/sql-server-2005-management-studio-installation7.jpg&quot; title=&quot;SQL Server 2005 Management Studio Installation upgrade is blocked&quot;&gt;&lt;br /&gt;&lt;img src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjc5N4LtxS_zvfHpBZD9FKGOv_Sls90p1jr9hmS-O9eSKawp1Uv9Tl07W-pR7i4hh7t3DVE2pojn5eVwepvqJlgXAtTlPz9z_yZDy1_DtqeUAe0sNLogzMBrQSe4EPGDvM4TRxrvcyY7E4/s400/sql-server-2005-management-studio-installation7.jpg&quot; style=&quot;display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 363px;&quot; border=&quot;0&quot; alt=&quot;/sql-server-2005-management-studio-installation&quot; id=&quot;BLOGGER_PHOTO_ID_5296460616433691970&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Now click &quot;Install&quot; button and install the client components! But why is it so, how would a normal user know that he needs to do it via command prompt with some flag, why isn&#39;t that flag available as some advanced installation option in UI itself  and why doesn&#39;t the error message provide some info about this possible (and in many cases, only) solution? Well, I&#39;ve to say that Microsoft and specifically whoever designed this Sql Server 2005 installed must be [...fill this one yourself...]</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/6037193635273014556/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/sql-management-studio-installation.html#comment-form' title='10 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6037193635273014556'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6037193635273014556'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/sql-management-studio-installation.html' title='SQL Server Management Studio not installed with Sql Server 2005 Installation'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUezUhfVTNmOi8grHNMCCKaWmQ-rdy2CCDMtkxJIX3HcEm_ZdgyRjlD8mrsrzhqiks93rAdXhGftlot5OhinWUy6K6k3ubOgZA0O6xI8TXb4ChfO0gVtTYIUSHsAf6J5kxBKM3Cz5TdEA/s72-c/sql-server-2005-management-studio-installation3.jpg" height="72" width="72"/><thr:total>10</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-5495523780636012123</id><published>2009-01-17T14:44:00.000-08:00</published><updated>2009-01-17T15:39:07.378-08:00</updated><title type='text'>Fetching Page Titles using jquery Ajax - RSH page title implementation</title><content type='html'>&lt;h3&gt;How to fetch Titles of HTML pages from URLs using jquery-ajax&lt;/h3&gt;&lt;br /&gt;There are many cases when we want to know the Titles of HTML pages without actually visiting them. One particular instance of this problem is when we are using &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;How to implement RSH Really Simple History&quot;&gt;RSH (Really Simple History)&lt;/a&gt;. This is because with RSH and/or Ajax page navigation, the page never reloads and so browser never changes the title of the page either. In this case, we need to programmatically fetch the titles and update the current page title with the fetched one.&lt;br /&gt;&lt;br /&gt;Unfortunately, there is no really clean way of fetching a page title through javascript other then fetching the whole page through Ajax and then parsing the HTML to extract the title. This is the technique that I&#39;m going to elaborate on in this article.&lt;br /&gt;&lt;br /&gt;Using jquery, the lines of code required is deceptively simple though! You can get the whole thing done, from fetching the HTML and updating the current title, in just about 2-3 lines of code! Below is how -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;$.get(&#39;yourlink.com&#39;, function(data){&lt;br /&gt;           document.title = data.toString().substring(data.toString().indexOf(&quot;&amp;lt;title&quot;, 0) + 7, data.toString().indexOf(&quot;&amp;lt;/title&quot;, 0));&lt;br /&gt;});&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Yes, that was it! I used jquery&#39;s &lt;span class=&quot;code&quot;&gt;$.get(link, callback)&lt;/span&gt; method that gets the contents of the link (passed as the first argument) through Ajax and then I just extracted the page title from the fetched HTML by javascript &lt;span class=&quot;code&quot;&gt;String.substring(indexStart, indexEnd)&lt;/span&gt; method. You&#39;ll also notice that the $.get()&#39;s callback has the argument called &quot;data&quot; that contains the returned or fetched HTML for the provided link. It works fine performance wise as well as we are not really doing any resource intensive operations on the fetched HTML (like displaying it somewhere, for example)&lt;br /&gt;&lt;br /&gt;Another thing I&#39;d like to note is the use of String.substring() method. It&#39;s not the cleanest way of doing it and a more &quot;correct&quot; way is to use javascript regular expression as in the below example -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;    document.title = data.toString().match(/\&amp;lt;title\&amp;gt;(*)\&amp;lt;\/title/);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;But the problem is that javascript has some limitations when it comes to regular expressions and the above code throws a &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2009/01/javascript-error-invalid-quantifier.html&quot; title=&quot;javascript invalid quantifier error for regular expressions&quot;&gt;invalid quantifier error&lt;/a&gt;. So, I decided to use the substring method in this case.&lt;br /&gt;&lt;br /&gt;To find how to use RSH (Really Simple History) to solve Ajax back button problem, click - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;How to implement RSH Really Simple History&quot;&gt;Implementing RSH (Really Simple History) for Ajax driven pages&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To learn how to call webservices easily using jquery and JSON, click - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/jquery-webservice-json-call-data.html&quot; title=&quot;Calling Webservices with jquery&#39;s Ajax and JSON without using ASP.NET&#39;s ScriptManager&quot;&gt;Calling Webservices with jquery&#39;s Ajax and JSON without using ASP.NET&#39;s ScriptManager&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/5495523780636012123/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/page-title-fetch-ajax-jquery.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5495523780636012123'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5495523780636012123'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/page-title-fetch-ajax-jquery.html' title='Fetching Page Titles using jquery Ajax - RSH page title implementation'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-8519671948338970486</id><published>2009-01-15T10:08:00.000-08:00</published><updated>2009-01-15T10:35:21.445-08:00</updated><title type='text'>The Controls collection cannot be modified because the control contains code blocks (i.e. &amp;lt;% ... %&amp;gt;)</title><content type='html'>&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;The Controls collection cannot be modified because the control contains code blocks (i.e. &amp;lt;% ... %&amp;gt;)&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So recently, I got the above error while trying to inject some dynamic tags into the head section of an ASP.NET 2.0 master page. Turns out that it&#39;s not possible to write a code like &lt;span class=&quot;code&quot;&gt;Header.Controls.Add(yourControl);&lt;/span&gt; if you are using code blocks to refer to stylesheets and js files and such -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;link href=&quot;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;&amp;lt;%=&lt;/span&gt; ResolveUrl(&quot;~/css/style.css&quot;) %&amp;gt;&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&lt;span style=&quot;font-weight: bold; color: rgb(204, 0, 0);&quot;&gt;&amp;lt;%=&lt;/span&gt; ResolveUrl(&quot;~/js/json.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;. etc&lt;br /&gt;&lt;br /&gt;So what gives? The most obvious solution is to of course get rid of code blocks but that&#39;s not always possible and might break some references if the user lands at some subfolders etc in your website.&lt;br /&gt;&lt;br /&gt;Next solution is to use databinding....i.e., replace &quot;&amp;lt;%=&quot; with &quot;&amp;lt;%#&quot; in the code blocks. So the above css and js references become the following -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;link href=&quot;&lt;span style=&quot;font-weight: bold; color: rgb(0, 102, 0);&quot;&gt;&amp;lt;%#&lt;/span&gt; ResolveUrl(&quot;~/css/style.css&quot;) %&amp;gt;&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen&quot; /&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&lt;span style=&quot;font-weight: bold; color: rgb(0, 102, 0);&quot;&gt;&amp;lt;%#&lt;/span&gt; ResolveUrl(&quot;~/js/json.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;. etc&lt;br /&gt;&lt;br /&gt;Since we are basically using the data binding expression &quot;&amp;lt;%#&quot; now for the head tag, you need to call the DataBind method after replacing &quot;&amp;lt;%=&quot; with &quot;&amp;lt;%#&quot; . That&#39;s just one extra line of code in your page load method -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;.....&lt;br /&gt;.....&lt;br /&gt;Head1.DataBind();&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;And, that&#39;s all there is! Problem solved!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/8519671948338970486/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/controls-collection-cannot-modified.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8519671948338970486'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8519671948338970486'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/controls-collection-cannot-modified.html' title='The Controls collection cannot be modified because the control contains code blocks (i.e. &amp;lt;% ... %&amp;gt;)'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-2157803206738577756</id><published>2009-01-14T19:12:00.000-08:00</published><updated>2009-01-15T11:05:22.712-08:00</updated><title type='text'>javascript error invalid quantifier in string.match regular expression</title><content type='html'>Yesterday I was trying to write some little regular expression to extract the title of a page from it&#39;s html and got the below error -&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;invalid quantifier *)\&amp;lt;\/title&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The actual code that generated this error was the following -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;data.toString().match(/\&amp;lt;title\&amp;gt;(*)\&amp;lt;\/title/);&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;The code works just as expected and extracts the page titles but it seems javascript doesn&#39;t support back references or something and that results in the &quot;invalid quantifier&quot; error in both Firefox and Internet Explorer.&lt;br /&gt;&lt;br /&gt;Anyhow, I replaced it with a substring (looking for &amp;lt;title and &amp;lt;\/title) and that works fine too. But if you know how to write a regular expression that does it without throwing this error, please share....</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/2157803206738577756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/javascript-error-invalid-quantifier.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/2157803206738577756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/2157803206738577756'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/javascript-error-invalid-quantifier.html' title='javascript error invalid quantifier in string.match regular expression'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-3230944892928959695</id><published>2009-01-06T11:48:00.001-08:00</published><updated>2009-01-06T12:20:10.637-08:00</updated><title type='text'>Could not load file or assembly System.Web.Extensions Version=1.0.61025.0 Culture neutral PublicKeyToken or one of its dependen</title><content type='html'>So today I tried to download and compile one of my old ASP.NET projects on a new system and ran into a host of errors! First I thought someone had made changes and checked in buggy code but Vault showed no changes for a few weeks! Among others was the below error -&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold; color: rgb(255, 0, 0);&quot;&gt;Could not load file or assembly &#39;System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=&lt;/span&gt;&lt;div style=&quot;color: rgb(255, 0, 0);&quot; class=&quot;gmail_quote&quot;&gt;&lt;wbr style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;31bf3856ad364e35&#39; or one of its dependencies. The system cannot find the file specified.    C:\Users\Owner\Documents\&lt;/span&gt;&lt;wbr style=&quot;font-weight: bold;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Visual Studio 2005\Websites\...\web.config&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;The culprit here is the System.Web.Extensions DLL from the old 1.x version (as the error message indicates). And the solution is to just download and install the Ajax extensions (ASP.net Ajax).&lt;br /&gt;&lt;br /&gt;The fun part though is - why Ajax extensions are required at all? That project doesn&#39;t use any of the Ajax controls! So why do we need to install an additional library? I guess it&#39;s because of the ASP.net Menu control being used in the project. But anyways, the solution is simple so let&#39;s just implement and get over with it!&lt;br /&gt;&lt;br /&gt;Ajax Extensions can be downloaded from - &lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyID=ca9d90fa-e8c9-42e3-aa19-08e2c027f5d6&amp;amp;displaylang=en&quot;&gt;ASP.NET AJAX 1.0&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;Once you download, install and restart your system, this particular error should disappear.&lt;br /&gt;&lt;br /&gt;In some other cases though (specially for ASP.net Ajax Extensions 3.5 library), the installation doesn&#39;t seem to register the DLLs in GAC (Global Assembly Cache). If that happens, just register the following files in GAC  -&lt;br /&gt;&lt;br /&gt;System.Web.Extensions.dll (this is that ASP.NET Ajax Extensions file)&lt;br /&gt;System.Web.Extensions.Design.dll&lt;br /&gt;Microsoft.Data.WebClient.dll&lt;br /&gt;Microsoft.Data.Web.dll&lt;br /&gt;Microsoft.Data.Web.Design.dll&lt;br /&gt;&lt;br /&gt;Please note that some of these files might already be registered in GAC so it might help to look them up first. Also, as you might already know, when checking if the file exists in GAC, always look at the name AND the version of the assembly because in .NET, just the name doesn&#39;t uniquely identify an assembly or DLL (this is how we can have System.Web.Extensions.dll Version 1.x and System.Web.Extensions.dll Version 3.x in the same folder in GAC).&lt;br /&gt;&lt;br /&gt;So that should take care of the &quot;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;Could not load file or assembly &#39;System.Web.Extensions,  &lt;/span&gt;&quot; error for all versions of System.Web.Extensions.dll&lt;br /&gt;&lt;br /&gt;Happy coding and a very wishing a very happy 2009 to you!&lt;br /&gt;&lt;br /&gt;To learn how to manage history with Ajax without using ASP.NET ScriptManager, click - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;Ajax History back button with RSH Really Simple History&quot;&gt;Ajax History back button with RSH (Really Simple History)&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To see a performance comparison of UpdatePanels with RSH, click - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/updatepanel-slow-performance-ajax.html&quot; title=&quot;ASP.NET Ajax UpdatePanel slow performance compared to jquery and RSH&quot;&gt;ASP.NET Ajax UpdatePanel slow performance compared to jquery and RSH - When to use and not use UpdatePanels&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To learn how to catch textbox change event without using ASP.NET Ajax, click - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2009/01/textbox-onchange-javascript-event.html&quot; title=&quot;Textbox onchange event in javascript client side&quot;&gt;Textbox onchange event in javascript / client side&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/3230944892928959695/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/could-not-load-file-or-assembly.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/3230944892928959695'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/3230944892928959695'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/could-not-load-file-or-assembly.html' title='Could not load file or assembly System.Web.Extensions Version=1.0.61025.0 Culture neutral PublicKeyToken or one of its dependen'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-1144443625562157221</id><published>2009-01-01T15:28:00.000-08:00</published><updated>2009-01-01T16:41:58.428-08:00</updated><title type='text'>Handling textbox onchange event in javascript</title><content type='html'>How to detect a change in textbox (or html input) on the clientside (javascript)? This is a common problem when &lt;span style=&quot;font-weight: bold;&quot;&gt;we want to do something as soon as textbox (input box) change &quot;event&quot; is fired&lt;/span&gt;.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Different ways textboxes (input fields) can be changed&lt;/h3&gt;1) Textbox change event fired by keyboard,&lt;br /&gt;&lt;br /&gt;2) Textbox change event raised because of copying into textbox via ctrl-c and ctrl-v (and mac equivalent)&lt;br /&gt;&lt;br /&gt;3) Textbox change event raised by copying into textbox via context menu (right mouse click and then left mouse click)&lt;br /&gt;&lt;br /&gt;4) Textbox change event fired by Autofill applications - this is often overlooked and difficult to control because the user could be using a variety of form filling applications out there including roboform, google&#39;s autofill, yahoo&#39;s autofill and so on.&lt;br /&gt;&lt;br /&gt;5) Textbox change triggered by the history stored by the browser - This is browser specific (firefox, safari) but still tricky as user hasn&#39;t typed anything, he/she has just moved focus to the textbox (via mouse click, tabs etc) and selected the values present in history by either mouse click or pressing enter key!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Specific example: &lt;/span&gt;We have a textbox (input field) for zipcodes and as user finishes typing the zipcode we want to update city and state fields to show the city/state for the entered zipcode. This is useful for doing a dynamic real time validation as well so that we can tell the user that his zipcode is invalid as soon as he enters it.&lt;br /&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;Possible solutions&lt;/h3&gt;1) Textbox onblur event - This is very good and works most of the time. But it&#39;ll be fired even if you move your mouse over the textbox so if your textbox change event handling mechanism involves any graphical changes (making things visible/invisible etc) then it might be disruptive.&lt;br /&gt;&lt;br /&gt;2) Textbox mouseout event - Works but not a complete solution as you need to handle keyboard and copy paste events too. Further, mouseout event is triggered when user clicks somewhere outside the textbox and not when he finishes typing! So, if your text change handler does things like updating another controls etc based on the new text in the textbox, then it won&#39;t work.&lt;br /&gt;&lt;br /&gt;3) Textbox onchange event - By far the best if combined with some additional code to disable copying/pasting something in the textbox. The copying/pasting can be easily handled in windows by detecting and invalidating control key press. One example of the code would be -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function OnTextChange(obj, e)&lt;br /&gt;{&lt;br /&gt; var isCtrl = false;&lt;br /&gt; if(window.event) {&lt;br /&gt;  key = e.keyCode;&lt;br /&gt;  isCtrl = window.event.ctrlKey&lt;br /&gt; }&lt;br /&gt; else if(e.which) {&lt;br /&gt;  key = e.which;&lt;br /&gt;  isCtrl = e.ctrlKey;&lt;br /&gt; }&lt;br /&gt; if(isCtrl)&lt;br /&gt;    return false;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Code presented above is not optimal and works only in windows but just to give some idea. Further, we still have the Autofill or Form filling applications or selecting the value from history (firefox) that can still change the textbox without triggering any event.&lt;br /&gt;&lt;br /&gt;4) Some browser specific solutions - onpaste attribute for input boxes (textbox) in firefox and I believe some safari specific attributes are also present. Some autofill variety of attributes are also present that can stop the autofilling for the whole form.&lt;br /&gt;&lt;br /&gt;5) In the context of ASP.net, one solution is to put the textbox in an updatepanel and catch the textbox&#39;s server side change event! But in my view &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/updatepanel-slow-performance-ajax.html&quot; title=&quot;ASP.net UpdatePanel slow performance&quot;&gt;UpdatePanels can get very slow in a variety of cases&lt;/a&gt; and severely disrupt the user experience and are recommended only if the scope is limited, user responsiveness is not a huge problem or you have a reason to believe that the they will perform consistently across all browsers and operating systems.&lt;br /&gt;&lt;br /&gt;Most solutions work as a combinations of above and by limiting the ways the user can actually enter the data, might solve the problem of handling the onchange event. I personally think that limiting the ways user can enter the data again disrupts the experience by violating the principle of least surprise! A user who is used to copying/pasting the SSN, zipcode or address (or any difficult to type/remember field) might hit back if ctrl-v doesn&#39;t do anything (&quot;form is broken&quot;). Another user who relies on autofill / form-fillers a lot might again abandon the form midway. Allowing the user to freedom to use whatever tools he wants to use to complete the form will obviously result in better results.&lt;br /&gt;&lt;h3&gt;&lt;br /&gt;&lt;/h3&gt;&lt;h3&gt;Final Solution for detecting any type of change in textbox&lt;/h3&gt;So, as you can see the core issue is that there is no textbox change event built in the browsers! This is logically so too because browser has no way of knowing when the user has finished changing the textbox other then some out of focus or mouse out events but they don&#39;t help us if we want to handle the textbox change immediately after use has finished it.&lt;br /&gt;&lt;br /&gt;This is more of a hack and not a very neat / clean solution but the good news is that &lt;span style=&quot;font-weight: bold;&quot;&gt;it takes care of *all* scenarios in which the user can change a textbox! &lt;/span&gt;Keyboard, mouse, pasting, selecting from history, autofill - they will all be handled perfectly without compromising user&#39;s experience.&lt;br /&gt;&lt;br /&gt;The basic premise is to check the textbox for any changes every 1-2 seconds and if any change is detected, trigger the onchange event handler. Sample code is below -&lt;br /&gt;&lt;br /&gt;1. Include this code in your scripts section -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;script language=&quot;javascript&quot; type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt; checkLastTextBoxValue($(&quot;[id$=textBox]&quot;).val());&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;This will basically run the checkLastTextBoxValue function as soon as the page is loaded. &quot;textBox&quot; is the id of your textbox (or input field) control. I&#39;ve added the $ sign to take care of the ASP.net&#39;s textbox control&#39;s client id issue.&lt;br /&gt;&lt;br /&gt;2. A sample function definition would be as follows -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function checkLastTextBoxValue (oldValue)&lt;br /&gt;{&lt;br /&gt; if($(&quot;[id$=textBox]&quot;).val() != oldValue)&lt;br /&gt; {&lt;br /&gt; if(String($(&quot;[id$=textBox]&quot;).val()).length == 5) //This is for USA zips&lt;br /&gt;{&lt;br /&gt;  zip = $(&quot;[id$=textBox]&quot;).val();&lt;br /&gt;         textBoxOnChangeEventHandler(zip);&lt;br /&gt;}&lt;br /&gt; }&lt;br /&gt;     setTimeout(&quot;checkLastTextBoxValue(&#39;&quot; + $(&quot;[id$=textBox]&quot;).val() + &quot;&#39;)&quot;, 1000);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;This code has three things to be noted -&lt;br /&gt;&lt;br /&gt;a. &lt;span class=&quot;code&quot;&gt;if($(&quot;[id$=textBox]&quot;).val() != oldValue)&lt;/span&gt;  - we compare &quot;old value&quot; with the &quot;current value&quot; in the textbox to simulate &quot;onchange&quot; event for the textbox! Not elegant but crafty and wickedly accurate!&lt;br /&gt;&lt;br /&gt;b. &lt;span class=&quot;code&quot;&gt;textBoxOnChangeEventHandler(zip);&lt;/span&gt; - we do what needs to be done after we have &quot;detected&quot; a change in the textbox here.&lt;br /&gt;&lt;br /&gt;c. &lt;span class=&quot;code&quot;&gt;setTimeout(&quot;checkLastTextBoxValue(&#39;&quot; + $(&quot;[id$=textBox]&quot;).val() + &quot;&#39;)&quot;, 1000);&lt;/span&gt; - pretty much the core of this textbox change event handling mechanism, this basically sets up the checkLastTextBoxValue function to run after a second. This doesn&#39;t eat up or block CPU though as we are taking 1000 milliseconds worth of break (and it can be more depending on our requirement) between the calls.&lt;br /&gt;&lt;br /&gt;So after much research and caffeine, I figured that this is the most robust and user-responsiveness-friendly solution for detecting textbox or input field changes.&lt;br /&gt;&lt;br /&gt;Feel free to comment.</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/1144443625562157221/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/textbox-onchange-javascript-event.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/1144443625562157221'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/1144443625562157221'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2009/01/textbox-onchange-javascript-event.html' title='Handling textbox onchange event in javascript'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-6524125430785542944</id><published>2008-12-30T10:36:00.000-08:00</published><updated>2008-12-30T14:11:06.162-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="jquery"/><category scheme="http://www.blogger.com/atom/ns#" term="UpdatePanel"/><category scheme="http://www.blogger.com/atom/ns#" term="UpdatePanel performance"/><category scheme="http://www.blogger.com/atom/ns#" term="Updatepanel safari"/><title type='text'>ASP.net UpdatePanel Slow Performance compared to jquery Ajax</title><content type='html'>I guess this won&#39;t come as a surprise for most of us veterans who have been using UpdatePanels for a little bit. For those who don&#39;t know what UpdatePanels are or do, a quick intro - UpdatePanel is a control shipped with ASP.NET Ajax that Ajaxifies server side calls from any controls that are put inside it. You can set the EnableHistory attribute in ScriptManager to true and you get the built in history (Ajax back button problem) as well! It&#39;s all out of the box and can save quite a bit of development time only but it&#39;s slow as sh-t!&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Let&#39;s look at a &quot;case study&quot; (that was my own project) -&lt;/h3&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Problem: &lt;/span&gt;Implement a &quot;wizard&quot; like functionality where the user steps through a number of questions presented one at a time.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Catch: &lt;/span&gt;Save answers to each question to the database as the user moves to the next question.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Bigger Catch: &lt;/span&gt;There must not be any page refreshes as user moves from one question to the next.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Insanely big Catch: &lt;/span&gt;Hitting browser&#39;s back button should take user to the previous question!&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Two Ajax &amp; Browser history solutions:&lt;/h3&gt;&lt;br /&gt;- ASP.NET Ajax&#39;s &lt;span style=&quot;font-weight: bold;&quot;&gt;UpdatePanel &lt;/span&gt;with ScriptManager&#39;s &lt;span style=&quot;font-weight: bold;&quot;&gt;EnableHistory &lt;/span&gt;set to True - UpdatePanel takes care of Ajax and EnableHistory attribute takes care of browser&#39;s back button.&lt;br /&gt;&lt;br /&gt;- &lt;span style=&quot;font-weight: bold;&quot;&gt;jquery ajax &lt;/span&gt;calls to a webservice with RSH (Really Simple History) - basically saving the answers (to the questions in wizard) via asynchronous jquery Ajax calls to some webservice. This takes care of stepping through the wizard and saving data without page refresh problems. Browser&#39;s history (back button) problem is solved by using RSH (Really Simple History) library.&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;Comparison of UpdatePanl ajax and jquery&#39;s ajax - &lt;/h3&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Performance comparison of UpdatePanel and jquery ajax: &lt;/span&gt;UpdatePanels suffer from some huge performance problems and can be ridiculously slow. As you see in the screenshot, 13 requests (yeah not a good number!) required 2MB. These requests are made by controls like DropDownLists, RadioButtons and Buttons, all wrapped in an UpdatePanel.&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;  title=&quot;ASP.net UpdatePanel slow performance Ajax&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5z14AIe9r5RWevPYjNM_5khOpssUyZBJZANFNvNgSsWvyhFMiQ02UEwZTPh_rh-BvDibdnaEuu8vXiHOkx7BPa7ahjuiIKJESt2OIvt3whQX5PAioIiVL579nUnn3LtoYAZs7b55nggw/s1600-h/updatepanel-ajax-slow.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 0px 0px 0pt; cursor: pointer; width: 400px; height: 53px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5z14AIe9r5RWevPYjNM_5khOpssUyZBJZANFNvNgSsWvyhFMiQ02UEwZTPh_rh-BvDibdnaEuu8vXiHOkx7BPa7ahjuiIKJESt2OIvt3whQX5PAioIiVL579nUnn3LtoYAZs7b55nggw/s400/updatepanel-ajax-slow.jpg&quot; alt=&quot;ASP.net UpdatePanel slow performance Ajax&quot; id=&quot;BLOGGER_PHOTO_ID_5285676731504888626&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;RSH and jquery ajax implementation, on the other hand, is much faster&lt;/span&gt;! As you see in the screenshot, we got away with only 103Kb of data with 20 jquery ajax calls! Compared to UpdatePanel, this is like a 300x improvement!&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;  title=&quot;Ajax jquery asynchronous calls&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdiBajUGaStJXLmUh4ehp1tGRNUdOexy5Vxt2PL7CiDTW3gY1DTaHfLPI6WxmpWNU7T7pcX_ZVE5dtamu6yFd4hxdDvEAc9wtAn_4DBWvgr_nUwCLKofT4NydsxY2qWW5sMDdk2oBjiOs/s1600-h/jquery-webservice-ajax-calls.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 0px 0px 0pt; cursor: pointer; width: 400px; height: 82px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgdiBajUGaStJXLmUh4ehp1tGRNUdOexy5Vxt2PL7CiDTW3gY1DTaHfLPI6WxmpWNU7T7pcX_ZVE5dtamu6yFd4hxdDvEAc9wtAn_4DBWvgr_nUwCLKofT4NydsxY2qWW5sMDdk2oBjiOs/s400/jquery-webservice-ajax-calls.jpg&quot; alt=&quot;Ajax jquery asynchronous calls&quot; id=&quot;BLOGGER_PHOTO_ID_5285677053251890770&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;The primary reason is that UpdatePanel posts back too much data but with jquery ajax calls, you send *only* the data you need to, to the server. Further, UpdatePanels try to recreate the whole control tree (Page) before sending it back in the response but with the jquery ajax thing you are in charge and you just need to hide the current question and show the next one (which would obviously be faster)!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Safari problems with UpdatePanel: &lt;/span&gt;As expected, UpdatePanels run even more slow in Safari and as expected (again) jquery ajax calls take about the same time. The below screenshots will help it visualize more clearly&lt;br /&gt;&lt;br /&gt;UpdatePanel performance in Safari -&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot;  title=&quot;ASP.net UpdatePanel slow performance Ajax for Safari browser&quot;href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZXimuMKFCBo0igiKENPESa-GV9Z22pOd4vdzs42pnldBgKYo2kEKt8hfNJPYMnPLHRguYh9jW3QL2Sshi_hxJ0GsCCc-4ke8_VlrdrvNDtUd6gTsmP1CpV06jItHTBYP6CV_CRRLTeK8/s1600-h/updatepanel-ajax-slow2.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 0px 0px 0pt; cursor: pointer; width: 400px; height: 384px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZXimuMKFCBo0igiKENPESa-GV9Z22pOd4vdzs42pnldBgKYo2kEKt8hfNJPYMnPLHRguYh9jW3QL2Sshi_hxJ0GsCCc-4ke8_VlrdrvNDtUd6gTsmP1CpV06jItHTBYP6CV_CRRLTeK8/s400/updatepanel-ajax-slow2.jpg&quot; alt=&quot;ASP.net UpdatePanel slow performance Ajax for Safari browser&quot; id=&quot;BLOGGER_PHOTO_ID_5285677533528052130&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;jquery ajax performance in Safari&lt;br /&gt;&lt;br /&gt;&lt;a onblur=&quot;try {parent.deselectBloggerImageGracefully();} catch(e) {}&quot; title=&quot;Ajax jquery asynchronous calls for Safari browser&quot; href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBbbRsyBSRiyfYUbHM2RhPeJq1tjAagvTobLcKkkJ4-Eh_aoj5Vt-kLxrN3TOrlzvWuQFmsWSQCi2EpCKWg68c5AIu-PbynYSAn52BaM1w9Yme402WzOfz3UEZA70z8IijZcB6_RwyQEQ/s1600-h/jquery-webservice-ajax-calls2.jpg&quot;&gt;&lt;img style=&quot;margin: 0pt 0px 0px 0pt; cursor: pointer; width: 400px; height: 306px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiBbbRsyBSRiyfYUbHM2RhPeJq1tjAagvTobLcKkkJ4-Eh_aoj5Vt-kLxrN3TOrlzvWuQFmsWSQCi2EpCKWg68c5AIu-PbynYSAn52BaM1w9Yme402WzOfz3UEZA70z8IijZcB6_RwyQEQ/s400/jquery-webservice-ajax-calls2.jpg&quot; alt=&quot;Ajax jquery asynchronous calls for Safari browser&quot; id=&quot;BLOGGER_PHOTO_ID_5285677312041104002&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;As you can see, the performance gains in Safari are rather huge!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Problems with URL fragments usage by UpdatePanels and RSH: &lt;/span&gt;This is again very important if your website has multiple tools / functionalities that rely on URL fragments. UpdatePanels don&#39;t play with any other tool / functionality that uses URL fragments. Yes, since UpdatePanels store their &quot;history&quot; in the URL fragments, if something else is also using URL fragments then ScriptManager&#39;s Navigate event (triggered by browser&#39;s back button) will not find it&#39;s &quot;history&quot;. This can be resolved though by putting in some checks to ensure that the current URL fragment is the one to be used by the UpdatePanel. Switching to RSH for all history management resolves this issue perfectly.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Development times comparison:&lt;/span&gt; Surprisingly, UpdatePanel ajax implementation doesn&#39;t save too much time over the jquery ajax implementation. If jquery were to be absent, then yeah UpdatePanel would generate quite a bit of code for us even for regular asynchronous web service calls. You won&#39;t be churning out 500 lines of jquery code for every line of UpdatePanel code! With jquery&#39;s ajax method, the amount of code written is pretty much the same (if not less)!&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Development technologies comparison: &lt;/span&gt;This is one of the key factors. With UpdatePanel you can write the code (saving data, moving to next question etc) in a server side language (C#, VB.NET etc) but with jquery ajax you are stuck with a client side language (javascript / jquery). The server side languages generally have better debugging tools and better built in features to allow better implementation from design, maintenance and coding efficiency point of view.  But it can very well be a personal thing.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Verdict: &lt;/span&gt;jquery ajax calls with RSH prove to be a better option if speed and versatility (across different browsers and OS etc) is a major concern. UpdatePanels might work better if the technological expertise and macro design details is a more important.&lt;br /&gt;&lt;br /&gt;To learn how to use RSH, click - &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH (Really Simple History) for Ajax back button problem&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;RSH (Really Simple History) for Ajax back button problem&lt;/span&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;To learn how to use jquery ajax, click - &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/jquery-webservice-json-call-data.html&quot; title=&quot;jquery ajax calls to webservices&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;jquery ajax calls to webservices&lt;/span&gt;&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/6524125430785542944/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/updatepanel-slow-performance-ajax.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6524125430785542944'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6524125430785542944'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/updatepanel-slow-performance-ajax.html' title='ASP.net UpdatePanel Slow Performance compared to jquery Ajax'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj5z14AIe9r5RWevPYjNM_5khOpssUyZBJZANFNvNgSsWvyhFMiQ02UEwZTPh_rh-BvDibdnaEuu8vXiHOkx7BPa7ahjuiIKJESt2OIvt3whQX5PAioIiVL579nUnn3LtoYAZs7b55nggw/s72-c/updatepanel-ajax-slow.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-8728073550819032898</id><published>2008-12-29T18:32:00.000-08:00</published><updated>2008-12-29T19:54:33.440-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Webservices"/><title type='text'>How to call a web service from jquery passing json data</title><content type='html'>Ok, so today I was finally able to rewrite all the asynchronous webservice calls with jquery using JSON for passing data from JQuery to Webservice (or is it Web service?) and getting result back from Webservice to jquery. For those who don&#39;t know whats going on, here&#39;s a little background info - As I noted in my previous posts, &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH Really Simple History&quot;&gt;RSH (Really Simple History)&lt;/a&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt; &lt;/span&gt;uses JSON quite a bit and &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/sysres-is-undefined-ajax-json.html&quot; title=&quot;RSH Really Simple History JSON doesn&#39;t work with ASP.net Ajax ScriptManager&quot;&gt;JSON doesn&#39;t seem to play well with Microsoft ASP.NET Ajax&#39;s (or Ajax.net if you prefer) ScriptManager control&lt;/a&gt; and I was using ScriptManager control to access my webservices from javascript (JQuery). Today, I finally figured out the best (or atleast easiest) way of calling webservice methods from jquery and using JSON for passing data (webservice&#39;s webmethod&#39;s arguments) to the webservice and getting the result back to jquery (result of the webmethod&#39;s call, yeah i&#39;m verbose!).&lt;br /&gt;&lt;br /&gt;And as you&#39;d expect, it made a hell lot of difference in performance! Now when I compare the approach of using a Webservice via a ScriptManager with this approach of calling the Webmethod directly via jquery, the performance improvement in the webservice calls are ridiculous! This is to be expected though as ASP.NET&#39;s Ajax ScriptManager generates a slew of helper client side scripts that totally bog the system down...err..ok not totally but the Webservice calls through ScriptManager do seem to add some kilobytes (can be over 100kb too) of extra code. Obviously, the jquery webservice calls implementation comes with it&#39;s own overhead too but I personally think that the jquery&#39;s overhead are not really deal breaker if you plan to write some little jquery helper functions yourself for making webservice calls. Besides the little fact that since the direct jquery with json webservice calls thingy doesn&#39;t require  a ScriptManager, you can do it in any language - asp.net, php, ruby, c, assembly....err not assembly I guess...but you get the picture!&lt;br /&gt;&lt;br /&gt;Anyhow, enough of my babbling, lets get on to the good stuff...some sample code to show how to go about calling a webservice from jquery (clientside, javascript whatever) via a ScriptManager (ASP.net ajax) and directly from jquery (again  clientside, javascript whatever) using json -&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;How to call a Webservice from jquery using ScriptManager - &lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;1.&lt;/span&gt; Import using System.Web.Script namespace and add ScriptService attribute to your webservice class. For example -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;using System.Web.Script;&lt;br /&gt;[ScriptService]&lt;br /&gt;public class OurPotentiallySlowWebService: System.Web.Services.WebService&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;2.&lt;/span&gt; Add WebMethod and ScriptMethod attributes to your web-methods that need to be called from javascript/jquery/clientside/mars....ok not mars. Example -&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;[WebMethod, ScriptMethod]&lt;br /&gt;public string SaveThisDataComingFromJQuery(string data1, data2)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;3.&lt;/span&gt; Add the following ScriptManager tag at the top of your form&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;asp:ScriptManager runat=&quot;server&quot; EnablePageMethods=&quot;true&quot; ID=&quot;BlahScriptManager&quot;&lt;br /&gt;EnableHistory=&quot;true&quot; EnablePartialRendering=&quot;true&quot; EnableStateHash=&quot;false&quot; OnNavigate=&quot;BlahScriptManager_Navigate&quot;&amp;gt;&lt;br /&gt;&amp;lt;Services&amp;gt;&lt;br /&gt;&amp;lt;asp:ServiceReference Path=&quot;~/OurPotentiallySlowWebService.asmx&quot; /&amp;gt;&lt;br /&gt;&amp;lt;/Services&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;4.&lt;/span&gt; Call the SaveThisDataComingFromJQuery method from your javascript -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;var finallyIGotResult = OurPotentiallySlowWebService.SaveThisDataComingFromJQuery (&quot;datavalue1&quot;, &quot;datavalue2&quot;);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Yes, that was it! ASP.NET Ajax ScriptManager has simplified the seemingly complex webservice call to ridiculous levels! But as I said, it came at a great cost of many extra kilobytes that might potentially slow your webpage down giving your visitor to hit back button and find some faster and more response website than yours! But fear not, you can do whatever that faster website did to become faster and stay in the game, read on....&lt;br /&gt;&lt;br /&gt;&lt;h3&gt;How to call Webservices from jquery and use JSON to pass data back and forth -&lt;/h3&gt;&lt;br /&gt;&lt;br /&gt;(&lt;span style=&quot;font-style: italic;&quot;&gt;First 2 steps will remain the same as above&lt;/span&gt; but I&#39;ve reproduced them below too just in case you knew the folly of ASP.net&#39;s ScriptManager and skipped the above section)&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;1.&lt;/span&gt; Import using System.Web.Script namespace and add ScriptService attribute to your webservice class. For example -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;using System.Web.Script;&lt;br /&gt;[ScriptService]&lt;br /&gt;public class OurFastestWebService: System.Web.Services.WebService&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;2.&lt;/span&gt; Add WebMethod and ScriptMethod attributes to your web-methods that need to be called from javascript/jquery/clientside/mars....ok not mars. Example -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;[WebMethod, ScriptMethod]&lt;br /&gt;public string SaveThisDataComingFromJQuery(string data1, data2)&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;3.&lt;/span&gt; Here the fun starts, you call the webmethod with the $.ajax method that totally rocks! Example -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;$.ajax({&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        type:&lt;/span&gt; &quot;POST&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        url:&lt;/span&gt; &quot;&lt;span style=&quot;font-weight: bold;&quot;&gt;OurFastestWebService.asmx/SaveThisDataComingFromJQuery&lt;/span&gt;&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        data:&lt;/span&gt; &quot;&lt;span style=&quot;font-weight: bold;&quot;&gt;{&#39;data1&#39;:&#39;datavalue1&#39;,&#39;data2&#39;:&#39;datavalue1&#39;}&lt;/span&gt;&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        contentType:&lt;/span&gt; &quot;application/json; charset=utf-8&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        dataType:&lt;/span&gt; &quot;json&quot;,&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        success:&lt;/span&gt; function(msg) { &lt;span style=&quot;font-weight: bold;&quot;&gt;var iGotResultAndPageisFaster = msg.d;&lt;/span&gt;  }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic;&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;        error:&lt;/span&gt; function(err) { alert(&#39;you don&#39;t deserve to write code&#39;);  }&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-style: italic; font-weight: bold;&quot;&gt;    });&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Holy sh-t! What&#39;s that &quot;thing&quot; above! Fear not, the good news is that &lt;span style=&quot;font-weight: bold;&quot;&gt;the bolded part on the right of colons is the only stuff you will change most of the time&lt;/span&gt;, still I take this piece of code apart below -&lt;br /&gt;&lt;br /&gt;$.ajax({ -&gt; This is the name of the jquery method. The little &quot;{&quot; at the end just means that we are sending the parameters / arguments to $.ajax in JSON format. JSON format is basically - {field1:value1, field2:value2}. JSON is a beauty in itself and I might write about it&#39;s advance usage later on but I hope you got the basic idea here.&lt;br /&gt;&lt;br /&gt;data -&gt; This is just the list of arguments and their values. Thing to keep in mind is that the the argument names here must match with the argument names used in the WebMethod. As you can see, I&#39;ve used &#39;data1&#39; and &#39;data2&#39; both here and in SaveThisDataComingFromJQuery WebMethod.&lt;br /&gt;&lt;br /&gt;Rest of the options are kinda self explanatory and won&#39;t change so I won&#39;t comment on them and seriously you should just make it work and go hit some clubs or something...but if you are married then you may visit http://docs.jquery.com/Ajax/jQuery.ajax#toptions for a fuller list of options.&lt;br /&gt;&lt;br /&gt;Yeah, it was *that* easy! So you see that, even if the ASP.net Ajax ScriptManager does help add some code on our behalf the webservice call easier but the difference is not *that* big even with Ajax. And if you add a helper method then even that little difference is eliminated.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;How to write a helper method for making $.Ajax calls to webservice -&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function iWannaCallMyFastestWebService(datavalue1, datavalue2)&lt;br /&gt;{&lt;br /&gt;$.ajax({&lt;br /&gt;   type: &quot;POST&quot;,&lt;br /&gt;   url: &quot;OurFastestWebService.asmx/SaveThisDataComingFromJQuery&quot;,&lt;br /&gt;   data: &quot;{&#39;data1&#39;:&#39;datavalue1&#39;,&#39;data2&#39;:&#39;datavalue1&#39;}&quot;,&lt;br /&gt;   contentType: &quot;application/json; charset=utf-8&quot;,&lt;br /&gt;   dataType: &quot;json&quot;,&lt;br /&gt;   success: function(msg) { var iGotResultAndPageisFaster = msg.d;  }&lt;br /&gt;   error: function(err) { alert(&#39;you don&#39;t deserve to write code&#39;);  }&lt;br /&gt;});&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Now you can call this method everywhere and bingo, you&#39;ve just eliminated the need (and overhead) of ScriptManager, ASP.net Ajax, Ajax.net, Microsoft, Global Warming,  completely.....ok not Global Warming but you got the point. Now let&#39;s compare the two method calls -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function iFunWithFastestWebservice()&lt;br /&gt;{&lt;br /&gt;&lt;span style=&quot;&quot;&gt;  iWannaCallMyFastestWebService(&quot;yoyo1&quot;, &quot;yoyo2&quot;);&lt;/span&gt;&lt;br /&gt;OurPotentiallySlowWebService.SaveThisDataComingFromJQuery (&quot;datavalue1&quot;, &quot;datavalue2&quot;);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Holy christ! It looks as if our jquery approach even saves some precious space for web service calls! So, now you the truth! Let the force be on your side, happy coding!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/8728073550819032898/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/jquery-webservice-json-call-data.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8728073550819032898'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8728073550819032898'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/jquery-webservice-json-call-data.html' title='How to call a web service from jquery passing json data'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-8665467452208374351</id><published>2008-12-24T09:21:00.000-08:00</published><updated>2008-12-29T19:52:07.195-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="JSON"/><category scheme="http://www.blogger.com/atom/ns#" term="ScriptManager"/><category scheme="http://www.blogger.com/atom/ns#" term="Sys.Res is undefined Sys.Net is undefined Sys.Application is undefined error ajax json"/><title type='text'>Sys.Res is undefined Sys.Net is undefined Sys.Application is undefined error ajax json</title><content type='html'>&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExLYME4bclxbMDs4oE9GvQMrPSUhY7flpMn9S9LUvQK5iuNT1Bkg-U0E8oeN7A5FoAqGoNBM7Ucc_RVN-EAp25YTkNc2FzD6gGavc84AoHMLr7AGgxC2Ic0s1qN7e627zdgoUSidTOe8/s1600-h/ajax-json-sysnet-undefined-error-bug.JPG&quot; title=&quot;&quot;&gt;&lt;img style=&quot;margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 400px; height: 62px;&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExLYME4bclxbMDs4oE9GvQMrPSUhY7flpMn9S9LUvQK5iuNT1Bkg-U0E8oeN7A5FoAqGoNBM7Ucc_RVN-EAp25YTkNc2FzD6gGavc84AoHMLr7AGgxC2Ic0s1qN7e627zdgoUSidTOe8/s400/ajax-json-sysnet-undefined-error-bug.JPG&quot; alt=&quot;&quot; id=&quot;BLOGGER_PHOTO_ID_5283408550407721570&quot; border=&quot;0&quot; /&gt;&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;So, switching to &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH (Really Simple History) for Ajax history browser back button&quot;&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;RSH (Really Simple History) for Ajax history back button management&lt;/span&gt; &lt;/a&gt;I, all of a sudden, started getting the below errors -&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;color: rgb(255, 0, 0);&quot;&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sys.Res is undefined&lt;/span&gt;&lt;br /&gt;/ScriptResource.axd?d=pAszYI1Gb4SpsTh8sMT0W6wF1gtmVrXttUVRBvK-ueW1CPqT8yfJ7elHbLz7SUAEaufrYfuec4EOs8rqAu5Babg0xkVae2w4D2gBh1dvVuE1&amp;amp;t=ffffffffa3435222&lt;br /&gt;Line 2798&lt;br /&gt;[Break on this error]  if (typeof(val) !== &#39;number&#39; || ...dOperation(Sys.Res.enumValueNotInteger);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sys.Net is undefined&lt;/span&gt;&lt;br /&gt;[Break on this error] BlahService.registerClass(&#39;BlahService&#39;,Sys.Net.WebServiceProxy);&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sys.Application is undefined&lt;/span&gt;&lt;br /&gt;[Break on this error] Sys.Application.initialize();&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;Sys.Net is undefined&lt;/span&gt;&lt;br /&gt;[Break on this error] BlahService.registerClass(&#39;BlahService&#39;,Sys.Net.WebServiceProxy);&lt;br /&gt;jsdebug (line 61)&lt;br /&gt;[Exception... &quot;Component is not available&quot; nsresult: &quot;0x80040111 (NS_ERROR_NOT_AVAILABLE)&quot; location: &quot;JS frame :: file:///C:/Program%20Files/Mozilla%20Firefox/components/nsSessionStore.js :: sss_saveState :: line 1908&quot; data: no]&lt;br /&gt;[Break on this error] this._writeFile(this._sessionFile, oState.toSource());&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;As you can see in the screenshot above as well, these errors are getting generated from inside ajax.net stuff and that&#39;s pretty much the most horrible source of errors/bugs thing that you can get! What I mean to say is that if the source of the error is some code written by some human, then it can be debugged and fixed but if the error is originating from some place like &lt;span style=&quot;font-style: italic;&quot; class=&quot;code&quot;&gt;ScriptResource.axd?d=pAszYI1Gb4SpsTh8sMT0W6wF1gtmVrXttUVRBvK-ueW1CPqT8yfJ7elHbLz7SUAEaufrYfuec4EOs8rqAu5Babg0xkVae2w4D2gBh1dvVuE1&amp;amp;t=ffffffffa3435222 &lt;/span&gt;then there&#39;s squat you can do to fix it! And even more so when one of the errors seems to say &lt;span class=&quot;code&quot;&gt;Sys.Application.initialize();&lt;/span&gt; then you know that you are doomed!&lt;br /&gt;&lt;br /&gt;Anyhow, after lots of caffeine, anguish and praying finally the &lt;span style=&quot;font-weight: bold;&quot;&gt;Lord Google revealed the answer&lt;/span&gt; - Turns out that &lt;span style=&quot;font-weight: bold;&quot;&gt;Microsoft&#39;s Ajax.net is not compatible with JSON&lt;/span&gt; (JSON being used by &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH (Really Simple History) for Ajax history browser back button&quot;&gt;RSH - Really Simple History plugin&lt;/a&gt;)! Go figure! Some little proof-of-concept showed that yes if I get rid of the ScriptManager control (that ships with Microsoft&#39;s Ajax.net) toolkit then all those errors will disappear.&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;asp:ScriptManager runat=&quot;server&quot; EnablePageMethods=&quot;true&quot; ID=&quot;BlahScriptManager&quot;&lt;br /&gt;EnableHistory=&quot;true&quot; EnablePartialRendering=&quot;true&quot; EnableStateHash=&quot;false&quot; OnNavigate=&quot;&lt;/span&gt;&lt;span class=&quot;code&quot;&gt;BlahScriptManager&lt;/span&gt;&lt;span class=&quot;code&quot;&gt;_Navigate&quot;&amp;gt;&lt;br /&gt;&amp;lt;Services&amp;gt;&lt;br /&gt;   &amp;lt;asp:ServiceReference Path=&quot;~/DynamicUpdater.asmx&quot; /&amp;gt;&lt;br /&gt;&amp;lt;/Services&amp;gt;&lt;br /&gt;&amp;lt;/asp:ScriptManager&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;So we are talking about either &lt;span style=&quot;font-weight: bold;&quot;&gt;getting rid of JSON or getting rid of ScriptManager control &lt;/span&gt;(or both for that matter!) as possible solutions. &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH (Really Simple History) for Ajax history browser back button&quot;&gt;RSH (Really Simple History)&lt;/a&gt; unfortunately relies on JSON and all of my asynchronous ajax (web service) calls rely on using ScriptManager with EnablePageMethods set to true (with the webservices referenced in the Services as you can see in the above code). Both RSH and the asynchronous calls (Webservice through the ScriptManager) are integral for the system but since Microsoft ajax.net won&#39;t play with JSON, I&#39;m scr-wed. But I guess we are all here to do what we are all here to do and I&#39;ll be implementing all the asynchronous webservice calls with regular XMLHttpRequest and I&#39;m guessing that it might even give some little performance boost given Microsoft Ajax&#39;s ScriptManager control is rather heavy duty stuff.&lt;br /&gt;&lt;br /&gt;Update: Dec 29 2008: I successfully implemented the aforementioned functionality, it turned out to be a much better option than using ScriptManager/ASP.net/Ajax and it didn&#39;t require a lot of extra code either. Read more here - &lt;a style=&quot;font-weight: bold;&quot; href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/jquery-webservice-json-call-data.html&quot; title=&quot;Calling Webservices from jquery using JSON&quot;&gt;Calling Webservices from jquery using JSON&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/8665467452208374351/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/sysres-is-undefined-ajax-json.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8665467452208374351'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/8665467452208374351'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/sysres-is-undefined-ajax-json.html' title='Sys.Res is undefined Sys.Net is undefined Sys.Application is undefined error ajax json'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhExLYME4bclxbMDs4oE9GvQMrPSUhY7flpMn9S9LUvQK5iuNT1Bkg-U0E8oeN7A5FoAqGoNBM7Ucc_RVN-EAp25YTkNc2FzD6gGavc84AoHMLr7AGgxC2Ic0s1qN7e627zdgoUSidTOe8/s72-c/ajax-json-sysnet-undefined-error-bug.JPG" height="72" width="72"/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-7654945201999746420</id><published>2008-12-19T19:10:00.000-08:00</published><updated>2010-03-12T09:13:20.001-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax Back Button"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax History"/><category scheme="http://www.blogger.com/atom/ns#" term="Really Simple History"/><category scheme="http://www.blogger.com/atom/ns#" term="RSH"/><title type='text'>How to implement RSH (Really Simple History) for Ajax History Back Button</title><content type='html'>&lt;b&gt;UPDATE (Mar 2010):&lt;/b&gt; I&#39;ve been looking for more easy to implement browser history management solutions and I think that &lt;b&gt;YUI is a better candidate than RSH&lt;/b&gt; in terms of the ease of implementation. Here is my new post on overview of history management solutions and a sample YUI implementation - &lt;b&gt;&lt;a href=&#39;http://web-win-programming-code-tutorial.blogspot.com/2010/03/yui-ajax-browser-history-back-button.html&#39; title=&#39;How to implement YUI Ajax Browser History Manager&#39;&gt;Implementing YUI Browser History Manager&lt;/a&gt;&lt;/b&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;How to use RSH Really Simple History &lt;/span&gt;- perhaps one of the best solutions to the Ajax history back button problem. For those who don&#39;t know about the ajax browser history and back button problem - browser&#39;s back button doesn&#39;t work for Ajax asynchronous calls because Ajax results in partial rendering of pages and therefore browser history is not recorded/saved for all Ajax asynchronous calls. Why - again because all Ajax calls result in partial web-page rendering and for browser history to work (for browser to know when to save the current state in history), a full page refresh has to happen. Browser&#39;s are just built that way and we can&#39;t really control the history management right out of the box. Another problem is that &lt;span style=&quot;font-weight: bold;&quot;&gt;browser&#39;s don&#39;t have any events for back and forward buttons&lt;/span&gt;. So even if we use something like URL Fragments to get the browser&#39;s back button to work for Ajax applications, still we wouldn&#39;t know if the user is going back or forward without any system that knows how to store the browser history in a stack and pop it when user hits browser&#39;s back button (specifically for ajax ofcourse).&lt;br /&gt;&lt;br /&gt;After looking at Gmail, Facebook and Orkut, I figured that a good Ajax browser history back button solution will use iframes and URL fragments in some way. Yeah, Gmail, Facebook and Orkut have flawless ajax history (back button) management. Yeah, &lt;span style=&quot;font-weight: bold;&quot;&gt;gmail has the most awesome ajax back button solution in place. Kudos google coders&lt;/span&gt; and designers! Facebook is also not lagging behind, you can see the URL fragments in Facebook&#39;s URL but it doesn&#39;t always seem to work properly (some times the page redirects!). Orkut too, is using some solution that relies on URL fragments and possibly iFrames. So looking at the ajax browser history (back button) managements in these social networking sites, I got some idea about what I&#39;m looking for and found this thing called RSH (Really Simple History) that seems like the perfect solution (so far).&lt;br /&gt;&lt;br /&gt;RSH (Really Simple History) &lt;span style=&quot;font-weight: bold;&quot;&gt;uses iFrames &lt;/span&gt;(and more for that matter!) to maintain the stack of browser&#39;s history. RSH (Really Simple History) also &lt;span style=&quot;font-weight: bold;&quot;&gt;uses URL fragments &lt;/span&gt;to store the browser history. Why - because remember that for an ajax asynchronous call browser doesn&#39;t even &quot;activate&quot; the back button. This URL fragments technique used by RSH (Really Simple History) is a hack to &quot;activate&quot; the back button because remember that the &lt;span style=&quot;font-weight: bold;&quot;&gt;browser&#39;s back button works for all URL fragment clicks&lt;/span&gt;. So, by updating the URL fragments Really Simple History (or RSH) create a &quot;state&quot; in browser&#39;s history. Yeah, Really Simple History is using iFrames to actually store the browser history stack for ajax calls and it&#39;s using URL fragments to make the browser&#39;s back button work for each of those ajax calls (tricking the browser into thinking that user navigated to some link! Neat RSH trick!).&lt;br /&gt;&lt;br /&gt;Ok, enough with the talk, &lt;span style=&quot;font-weight: bold;&quot;&gt;lets get back to how to implement RSH &lt;/span&gt;or Really Simple History. (Yes, that&#39;s kinda the main point of the blog because very few sites explain how to use or how to implement Really Simple History (RSH). Please remember that the code samples I provide below come from ASP.NET development environment but being Javascript/JQuery (clientside code basically) there&#39;s not much difference.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;1:&lt;/span&gt; Download &lt;span style=&quot;font-weight: bold;&quot;&gt;JQuery &lt;/span&gt;and include in your web page (skip if already using them). JQuery can be downloaded from &lt;a href=&quot;http://docs.jquery.com/Downloading_jQuery&quot;&gt;JQuery Download for RSH (Really Simple History)&lt;/a&gt; and JQuery version (1.2.6 in the code below) will change as per the latest JQuery version you download.&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/jquery-1.2.6.min.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;2:&lt;/span&gt; Download &lt;span style=&quot;font-weight: bold;&quot;&gt;RSH (Really Simple History) &lt;/span&gt;library from &lt;a href=&quot;http://code.google.com/p/reallysimplehistory/downloads/list&quot;&gt;http://code.google.com/p/reallysimplehistory/downloads/list&lt;/a&gt; and include the the minified JQuery and &lt;span style=&quot;font-weight: bold;&quot;&gt;JSON &lt;/span&gt;files (again the version numbers will change as per your latest RSH and JSON versions download).&lt;br /&gt;&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/json2007.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/rsh.compressed.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;(JSON2007.js and JSON2005.js were included in the Really Simple History package so I didn&#39;t have to download JSON separately).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;3:&lt;/span&gt; FTP or Upload blank.html (that is there in RSH package) to your website where you want to use Really Simple History. This is important because Really Simple History uses the blank.html file to store the browser history stack (as an iframe in your main web page).&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;4:&lt;/span&gt; Create a method that handles any changes in history events. Please remember from earlier in this article that browsers don&#39;t have any events for back and forward buttons so we can&#39;t handle them (the back button navigation specifically). Now, Really Simple History can handle back (and forward) button on your behalf and all you need to do is to provide a function that takes a stored history state (that you store a bit later in this article) and decides what to do. If this doesn&#39;t make a lot of sense, hang on and just look at the sample code for that method below. I&#39;ll explain it in more detail in a little bit.&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function historyChange(newLocation, historyData)&lt;br /&gt;{&lt;br /&gt;&lt;br /&gt;ShowOldContent(newLocation, historyData);&lt;br /&gt;&lt;br /&gt;// OR to simplify&lt;br /&gt;&lt;br /&gt;alert(&#39;hey I&#39;m going back to &#39; + newLocation);&lt;br /&gt;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;5:&lt;/span&gt; Execute the dhtmlHistory.initialize and dhtmlHistory.addListener methods to your onload function to initialize Really Simple History and create the appropriate listeners respectively. Sample code follows and please take a look at the comments for more clarification -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;window.onload = function() {&lt;br /&gt;//Simply initializes the dhtmlHistory object. No change needed.&lt;br /&gt;dhtmlHistory.initialize();&lt;br /&gt;&lt;br /&gt;//Adds a listener for browser&#39;s back/forward navigation. Just change &quot;historyChange&quot; to&lt;br /&gt;// your method of choice. Note that &quot;historyChange&quot; comes from step 4 above.&lt;br /&gt;dhtmlHistory.addListener(historyChange);&lt;br /&gt;&lt;br /&gt;//This adds a starting point to the whole browser history thingy. Not really optional though.&lt;br /&gt;dhtmlHistory.add(&#39;default.aspx&#39;,&#39;link&#39;);&lt;br /&gt;&lt;br /&gt;};&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Please note that whatever you put in dhtmlHistory.add() function, as the first argument, will show up as a URL fragment in your webpage. So if your webpage is http://www.mywebpage.com/ then it will become http://www.mywebpage.com/#default.aspx if default.aspx was your first argument to dhtmlHistory.add() function.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;6:&lt;/span&gt; Call dhtmlHistory.add() function wherever you want to store the browser history for ajax calls! For example, in your buttons that do some ajax calls, you can call it in the onclick() method. What the dhtmlHistory.add() function will do is to call your historyChange() method in turn and execute your history management code.&lt;br /&gt;&lt;br /&gt;So, the final sample code looks like -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/json2007.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/jquery-1.2.6.min.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/rsh.compressed.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; language=&quot;javascript&quot;&amp;gt;&lt;br /&gt;window.onload = function() {&lt;br /&gt;dhtmlHistory.initialize();&lt;br /&gt;dhtmlHistory.addListener(historyChange);&lt;br /&gt;dhtmlHistory.add(&#39;default.aspx&#39;,&#39;link&#39;);&lt;br /&gt;};&lt;br /&gt;&lt;br /&gt;function historyChange(newLocation, historyData)&lt;br /&gt;{&lt;br /&gt;ShowOldContent(newLocation, historyData);&lt;br /&gt;// OR to simplify&lt;br /&gt;alert(&#39;hey I&#39;m going back to &#39; + newLocation);&lt;br /&gt;}&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Yes! You are done! It&#39;s as simple as that!&lt;br /&gt;&lt;br /&gt;Sample Implementation: Now let&#39;s go over a sample implementation because so far it was all pretty much up in the air and you might not be sure about what to put in historyChange() method and what to pass as arguments in dhtmlHistory.add() method and so on. So, I&#39;ll present two  sample implementations of RSH (Really Simple History) . One is a a wizard like problem and the other is navigating using links in a fancy ajax way. This is what I had to do myself in various different projects.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;How to use RSH (Really Simple History) to implement (anchor tags) navigation&lt;/span&gt; - This is a common problem in which the user clicks a link (anchor tag) and the whole page goes back for a second as new page is loaded. This interferes with the user&#39;s overall experience and might even drive him away the more impatient ones. No need to say that a seamless link (anchors) navigation can help most e-commerce websites considerably. This was always considered a necessary evil though but with RSH (Really Simple History) has come to our rescue and here I present one easy solution to integrate Ajax with page navigation -&lt;br /&gt;&lt;br /&gt;1: Attach dhtmlHistory.Add() to all anchor tags&#39;s onclick() event handlers&lt;br /&gt;2: Call $(&#39;#&lt;your&gt;&#39;).load(&lt;your&gt;) in your historyChange() function&lt;br /&gt;&lt;br /&gt;And you are done! Yeah, that was it! I&#39;ll be writing in more details about it though as I think it&#39;s a rather big topic in itself if presented with all the required code etc.&lt;br /&gt;&lt;br /&gt;&lt;span style=&quot;font-weight: bold;&quot;&gt;How to use RSH (Really Simple History) to implement Ajax driven wizards&lt;/span&gt; - Let&#39;s say we have a drop down (select) as step 1 and 2 radio buttons in our body tag -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;h1&amp;gt;Ajax driven Wizard&amp;lt;/h1&amp;gt;&lt;br /&gt;&amp;lt;div id=&quot;divStep1&quot;&amp;gt;&lt;br /&gt;&amp;lt;asp:DropDownList ID=&quot;ddlStep1&quot; runat=&quot;server&quot;&amp;gt;&lt;br /&gt;&amp;lt;asp:ListItem Value=&quot;&quot;&amp;gt;Please Select&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;&amp;lt;asp:ListItem Value=&quot;itep1&quot;&amp;gt;item1&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;&amp;lt;asp:ListItem Value=&quot;itep2&quot;&amp;gt;item2&amp;lt;/asp:ListItem&amp;gt;&lt;br /&gt;&amp;lt;/asp:DropDownList&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;div id=&quot;divStep1&quot;&amp;gt;&lt;br /&gt;&amp;lt;asp:RadioButton runat=&quot;server&quot; groupName=&quot;rbStep2a&quot; ID=&quot;rbStep2&quot;  /&amp;gt;&lt;br /&gt;&amp;lt;asp:RadioButton runat=&quot;server&quot; groupName=&quot;rbStep2b&quot; ID=&quot;rbStep2&quot;  /&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;We attach the javascript event handlers to above as follows (one of the many ways of attaching event handlers) -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;ddlStep1.Attributes[&quot;onchange&quot;] = &quot;moveNext(&#39;step2&#39;)&quot;;&lt;br /&gt;rbStep2a.Attributes[&quot;onclick&quot;] = moveNext(&#39;step1&#39;)&quot;;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;&quot;moveNext&quot; is just some method here that shows the &quot;next&quot; step of the wizard and and saves the data to database so that you can keep track of the intermediate steps of a wizard in case user leaves in the middle&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function moveNext(nextStep)&lt;br /&gt;{&lt;br /&gt;if(nextStep == &#39;step2&#39;)&lt;br /&gt;{&lt;br /&gt;$(&quot;#divStep2&quot;).show();&lt;br /&gt;$(&quot;#divStep1&quot;).hide()&lt;br /&gt;}&lt;br /&gt;else if(nextStep == &#39;step1&#39;)&lt;br /&gt;{&lt;br /&gt;$(&quot;#divStep1&quot;).show();&lt;br /&gt;$(&quot;#divStep2&quot;).hide()&lt;br /&gt;}&lt;br /&gt;dhtmlHistory.add(nextStep,&#39;WizardStep&#39;);&lt;br /&gt;saveToDatabase(nextStep);&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Yes, the above code will create a cyclic not-so-much-of-a-wizard! Please give special attention to the bolded line. This line actually adds the &quot;next step&quot; to browser history and as soon as it&#39;s executed you will see #&lt;nextstep&gt; as a URL Fragment. Yeah, that&#39;s RSH at work right there.&lt;br /&gt;&lt;br /&gt;Using above as a reference, we can write historyChange method as below. This implementation too just shows the &quot;next&quot; div and looks a lot like moveNext() method above but it can change to do anything as per your requirements.&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function historyChange(newLocation, historyData)&lt;br /&gt;{&lt;br /&gt;if(newLocation == &#39;step2&#39;)&lt;br /&gt;{&lt;br /&gt;$(&quot;#divStep2&quot;).show();&lt;br /&gt;$(&quot;#divStep1&quot;).hide()&lt;br /&gt;}&lt;br /&gt;else if(newLocation == &#39;step1&#39;)&lt;br /&gt;{&lt;br /&gt;$(&quot;#divStep1&quot;).show();&lt;br /&gt;$(&quot;#divStep2&quot;).hide()&lt;br /&gt;}&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Please note that I haven&#39;t use the historyData object at all in the above example because I simply didn&#39;t need to store anything else. But if I need to store something then yes, we can put anything we want in the historyData object. So, thats how we can use RSH (Really Simple History) for an Ajax driven wizard that allows the user to use back button to go back to the last question (and saves the data to the database as a bonus) with refreshing the page!&lt;/nextstep&gt;&lt;/your&gt;&lt;/your&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/7654945201999746420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html#comment-form' title='21 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/7654945201999746420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/7654945201999746420'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html' title='How to implement RSH (Really Simple History) for Ajax History Back Button'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>21</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-5725670075078682231</id><published>2008-12-15T14:21:00.001-08:00</published><updated>2008-12-20T11:51:42.595-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="jquery bug"/><category scheme="http://www.blogger.com/atom/ns#" term="name.replace is not a function"/><title type='text'>name.replace is not a function - jquery bug</title><content type='html'>While trying to implement RSH (Really Simple History, check out my &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;RSH Really Simple History Ajax Back Button History&quot;&gt;how to implement RSH - Really Simple History and solve ajax history back button problem&lt;/a&gt; article for details), I got this dreaded &quot;name.replace is not a function&quot; error! It really drove me nuts as many seem to have got it reported it to the jquery team but for whatever reason jquery bugtracker has almost always marked it as resolved or moved to subcategories. That might all be right but the problem is that this error is still there and seems to emerge right from the jquery core file! I mean it&#39;s alright that jquery team has found it to be an invalid bug or resolved issue or relating strictly to jquery plugins (instead of jquery core) but when I see &quot;name.replace is not a function&quot; popping up in my webpage I have to do something to fix it, lol! And I can&#39;t do squat because on tracing back, I realize that &quot;name.replace is not a function&quot; is originating from the jquery core file!&lt;br /&gt;&lt;br /&gt;So what to do? I personally did the following -&lt;br /&gt;&lt;br /&gt;1) Do whatever needs to be done and make sure that the desired functionality is still maintained. That is, isolate the error producing code such that your functionality is not impacted by the error.&lt;br /&gt;&lt;br /&gt;2a) Either change the browser settings to not show the error if you have less than 10 users who can&#39;t really tell a browser from a pumpkin pie.&lt;br /&gt;&lt;br /&gt;2b) If you have some user base and most importantly if it&#39;s an internet application then do this thing that is both next best and next worst to the above approach! ;) Yeah, trap the silly &quot;name.replace is not a function&quot; error in a try catch block. This is bad because you&#39;ve just hidden some error beyond redemption but the thing is that if you&#39;ve done step 1 correctly then it doesn&#39;t matter all that much. So I just went ahead and did it. Below are steps to how to do it -&lt;br /&gt;&lt;br /&gt;a) Search for name=name.replace in jquery-1.2.6.min.js file (or the not-minified version and your version number replaces 1.2.6 obviously).&lt;br /&gt;&lt;br /&gt;b) Ignore the name=name.replace that has &quot;&quot;float&quot;;&quot; before &quot;name=name.replace&quot; part. Yeah, there are two of the name=name.replace thingees.&lt;br /&gt;&lt;br /&gt;c) add a try block before name and close it with a catch block just before the immediate &quot;if&quot; statement.&lt;br /&gt;&lt;br /&gt;So initially it was like this -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;opacity=([^)]*)/)[1])/100)+&#39;&#39;:&quot;&quot;;}&lt;span style=&quot;font-weight: bold;&quot;&gt;name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});&lt;/span&gt;if(set)elem[name]&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;And after our little change, it looks like  -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;opacity=([^)]*)/)[1])/100)+&#39;&#39;:&quot;&quot;;}&lt;span style=&quot;font-weight: bold;&quot;&gt;try{&lt;/span&gt;name=name.replace(/-([a-z])/ig,function(all,letter){return letter.toUpperCase();});&lt;span style=&quot;font-weight: bold;&quot;&gt;}catch(e){}&lt;/span&gt;if(set)elem[name]&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Bingo! The stupid name.replace has finally decided to be a function now! The error is gone and if you&#39;ve been struggling to &quot;somehow&quot; make it work before you can hit the clubs tonight then you are free to do so! Yeah, do it before some new yet unknown error pops out!</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/5725670075078682231/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/namereplace-is-not-function-jquery-bug.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5725670075078682231'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/5725670075078682231'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/namereplace-is-not-function-jquery-bug.html' title='name.replace is not a function - jquery bug'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-2102007884459060816.post-6550086322978133127</id><published>2008-12-15T13:58:00.000-08:00</published><updated>2008-12-20T12:01:57.157-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Ajax"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax Back Button"/><category scheme="http://www.blogger.com/atom/ns#" term="Ajax History"/><category scheme="http://www.blogger.com/atom/ns#" term="History Remote plugin"/><title type='text'>Browser History Back Button - History/Remote Plugin</title><content type='html'>This particular solution applies to the cases when we want to stop any visible page refreshes as the user browses through the website. What we are trying to do basically is to load a new page as the user clicks on a link (navigates via a link) without refreshing the browser - That is, loading the part of the new page in our current page via Ajax by partially rendering the new content in the current page. But because of partial rendering of the page (the fact that the page is never refreshed), the back button gets lost. This plugin solves the back button browser history problem for this scenario using URL fragments.&lt;br /&gt;&lt;br /&gt;Step 1: Download the latest jquery library from http://jquery.com/and include it in your project as follows -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/jquery-1.2.6.min.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt; &lt;/span&gt;(Please remember that this is just an example and the method/filenames etc will change depending on the names used in your web-development language / platform and jquery version etc.&lt;br /&gt;&lt;br /&gt;Step 2: Download history/remote plugin js files from http://stilbuero.de/jquery/history/ (this is the website of Mr. Klaus Hartl, the gentleman who came up with this solution) and include it in your project as follows -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;&amp;lt;script type=&quot;text/javascript&quot; src=&quot;&amp;lt;%= ResolveUrl(&quot;~/js/jquery.history_remote.js&quot;) %&amp;gt;&quot;&amp;gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Step 3: Add a class named &quot;seolink&quot; to all your links (anchor tags) that needs history management. Please note that this class doesn&#39;t exist in your css file and doesn&#39;t have any display attributes, it&#39;s solely for the purpose of history management.&lt;br /&gt;&lt;br /&gt;Step 4: Add the below code (jquery script) in the head tag of the webpage (or the master template if you are using asp.net masterpages) -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;$(document).ready(function() {&lt;br /&gt;&amp;nbsp;            createSeoLinks($(&quot;#navigation a&quot;).add(&quot;a.seolink&quot;));&lt;br /&gt;&amp;nbsp;            $.ajaxHistory.initialize(function (){$(&quot;#main-content&quot;).load(location.href   &quot; #main-content &amp;gt; *&quot;)});&lt;br /&gt;&amp;nbsp;     });&lt;br /&gt;&lt;br /&gt;function createSeoLinks(links) {&lt;br /&gt;&amp;nbsp;            links.unbind(&#39;click&#39;).remote(&#39;#main-content&#39;, function() {&lt;br /&gt;&amp;nbsp;window.createSeoLinks($(&quot;#main-content a.seolink&quot;));&lt;br /&gt;&amp;nbsp;         });&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Step 5 (optional): Ensure that all the links (anchor tags) have title attributes properly set&lt;br /&gt;&lt;br /&gt;Step 6 (optional): Add the below code to the $(document).ready(function()  section -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;document.title = convertLinkToTitle(window.location);&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;If you don&#39;t know what Step 6 means, the final code in Step 4 will look like this -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;$(document).ready(function() {&lt;br /&gt;&amp;nbsp;            createSeoLinks($(&quot;#navigation a&quot;).add(&quot;a.seolink&quot;));&lt;br /&gt;&amp;nbsp;            $.ajaxHistory.initialize(function (){$(&quot;#main-content&quot;).load(location.href   &quot; #main-content &amp;gt; *&quot;)});&lt;br /&gt;&amp;nbsp;     });&lt;br /&gt;&lt;br /&gt;function createSeoLinks(links) {&lt;br /&gt;&amp;nbsp;            links.unbind(&#39;click&#39;).remote(&#39;#main-content&#39;, function() {&lt;br /&gt;&amp;nbsp;                window.createSeoLinks($(&quot;#main-content a.seolink&quot;));&lt;br /&gt;&amp;nbsp; document.title = convertLinkToTitle(window.location);&lt;br /&gt;&amp;nbsp;         });&lt;br /&gt;     }&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;And you are done! Yes, it was that easy!&lt;br /&gt;&lt;br /&gt;Now, let explain a few things in the above code -&lt;br /&gt;&lt;br /&gt;1) main-content : Refers to the div that contains the content that you want to load whenever a link is clicked. Remember that only the contents of main-content div will change as the user navigates through the website, so you will need to organize your content so that the static elements are kept out of main-content div. It doesn&#39;t matter a hell lot though but this organization is a good idea in general.&lt;br /&gt;&lt;br /&gt;2) What is in addressbar - Remember that, since the page i snever refreshed, the only thing in addressbar that will change is the url fragment. This is picked from the title of anchor tags and that&#39;s why Step 5 is needed. It&#39;s not an essential component of the history management process though and if you leave it out then it will be &quot;#remote&quot; followed by some number - (like #remote25 for 25th anchor tag etc)&lt;br /&gt;&lt;br /&gt;3) convertLinkToTitle - Again since the page is never refreshed, the page title never really changes. So, I figured that I should update the page title programmatically using the information in the browser&#39;s addressbar. So this is a javascript / jquery function that will take the link (in the browser&#39;s addressbar) and figure out what the title should be, you will be writing the code yourself depending on what you want in url fragment (or the url itself) and how to translate it into page titles. The way, I wrote it is below -&lt;br /&gt;&lt;span class=&quot;code&quot;&gt;&lt;br /&gt;function convertLinkToTitle(linkStr)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;    var title = new String();&lt;br /&gt;&amp;nbsp;    title = String(linkStr);&lt;br /&gt;&amp;nbsp;    title = title.substr(title.indexOf(&#39;#&#39;, 0)   1);&lt;br /&gt;&amp;nbsp;    title = title.replace(/_/g, &#39; &#39;);&lt;br /&gt;&amp;nbsp;    return title;&lt;br /&gt;}&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;So this is how you implement the History/Remote Plugin.....feel free to suggest improvements, ask questions or comment on the code....And click - to read about another (and in my opinion) better &lt;a href=&quot;http://web-win-programming-code-tutorial.blogspot.com/2008/12/ajax-history-back-rsh-really-simple.html&quot; title=&quot;Ajax Browser History Back Button solution RSH Really Simple History&quot;&gt;Ajax Browser History Back Button solution called RSH (Really Simple History)&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://web-win-programming-code-tutorial.blogspot.com/feeds/6550086322978133127/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/browser-history-back-button.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6550086322978133127'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/2102007884459060816/posts/default/6550086322978133127'/><link rel='alternate' type='text/html' href='http://web-win-programming-code-tutorial.blogspot.com/2008/12/browser-history-back-button.html' title='Browser History Back Button - History/Remote Plugin'/><author><name>Ambi Advaita</name><uri>http://www.blogger.com/profile/16890663767569745190</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='30' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjVv0QiqmdDxe_plsQsQe_KmEn1rNM3gY00nDtvrar3D8N0BXjyDqz9_6c4hStw-3LiWPcOfTQizEesqdKcKbVXBN1jTPINu8vpHbfa9UOE00WCwTWEFuMDdMFEmFbqB-c/s220/dkrbruce.jpg'/></author><thr:total>0</thr:total></entry></feed>