<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Pure Blue &#187; Gotcha&#8217;s</title>
	<atom:link href="http://blog.pureblue.co.nz/category/gotchas/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.pureblue.co.nz</link>
	<description>.NET and other things</description>
	<lastBuildDate>Mon, 18 Apr 2011 00:16:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='blog.pureblue.co.nz' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Pure Blue &#187; Gotcha&#8217;s</title>
		<link>http://blog.pureblue.co.nz</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://blog.pureblue.co.nz/osd.xml" title="Pure Blue" />
	<atom:link rel='hub' href='http://blog.pureblue.co.nz/?pushpress=hub'/>
		<item>
		<title>Warning: ASP.NET MVC RC FormCollection bug</title>
		<link>http://blog.pureblue.co.nz/2010/01/25/warning-asp-net-mvc-rc-formcollection-bug/</link>
		<comments>http://blog.pureblue.co.nz/2010/01/25/warning-asp-net-mvc-rc-formcollection-bug/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 22:45:54 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[ASP.NET MVC]]></category>
		<category><![CDATA[Gotcha's]]></category>

		<guid isPermaLink="false">http://blog.pureblue.co.nz/?p=128</guid>
		<description><![CDATA[UPDATE: This post refers to ASP.NET MVC 2 R1. The R2 release on 4th Feb 2010 fixed the issue. I started to update an ASP.NET MVC 1.0 application to the new MVC 2.0 RC but will now put off that migration for now &#8211; I&#8217;ll wait for the RTM which should fix this. The problem [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=128&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE</strong>: This post refers to ASP.NET MVC 2 R1. The R2 release on 4th Feb 2010 <a href="http://blog.pureblue.co.nz/2010/02/06/asp-net-mvc-2-r2-released/" target="_blank">fixed the issue</a>.</p>
<p>I started to update an ASP.NET MVC 1.0 application to the new MVC 2.0 RC but will now put off that migration for now &#8211; I&#8217;ll wait for the RTM which should fix this.</p>
<p>The problem is to do with the FormCollection object throwing an ArgumentException (&#8220;Value cannot be null or empty&#8221;) when calling TryUpdateModel from within your controller:</p>
<p><span style="font-family:Courier;font-size:xx-small;">at System.Web.Mvc.FormCollection.GetValue(String name) <br />
at System.Web.Mvc.DefaultModelBinder.BindModel(ControllerContext controllerContext, ModelBindingContext bindingContext) <br />
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, String prefix, String[] includeProperties, String[] excludeProperties, IValueProvider valueProvider) <br />
at System.Web.Mvc.Controller.TryUpdateModel[TModel](TModel model, IValueProvider valueProvider) </span></p>
<p>This is apparently a <a href="http://stackoverflow.com/questions/1936970/asp-net-mvc-2-problem-with-updatemodel" target="_blank">known issue with the RC release </a>and should be fixed in the next release. The project I am working on is fairly sizable and with the many uses of FormCollection, a lot of runtime errors have been created!</p>
<p>One suggested solution is to <a href="http://www.blogs.victorero.com/2010/01/21/UsingTheASPNETMVC20RCSourceCodeToCorrectABug.aspx" target="_blank">download the MVC source code and make a fix</a> (hack?) to by-pass the issue. However, I&#8217;d rather stay on the main MVC branch and just wait for the RTM.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pureblue.wordpress.com/128/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pureblue.wordpress.com/128/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pureblue.wordpress.com/128/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=128&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pureblue.co.nz/2010/01/25/warning-asp-net-mvc-rc-formcollection-bug/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e87832b33c29d5158683a1f55eff7700?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
		<item>
		<title>Clicking a button in Javascript doesn&#8217;t always work in Firefox</title>
		<link>http://blog.pureblue.co.nz/2008/02/14/clicking-a-button-in-javascript-doesnt-always-work-in-firefox/</link>
		<comments>http://blog.pureblue.co.nz/2008/02/14/clicking-a-button-in-javascript-doesnt-always-work-in-firefox/#comments</comments>
		<pubDate>Thu, 14 Feb 2008 02:03:43 +0000</pubDate>
		<dc:creator>Matthew</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Gotcha's]]></category>

		<guid isPermaLink="false">http://pureblue.wordpress.com/?p=27</guid>
		<description><![CDATA[I&#8217;ve run into a javascript problem a few times which -for a refreshing change &#8211; shows itself as Firefox not behaving as you might expect (&#8230; well Firefox together with ASP.NET at any rate). The issue surfaces when you try and invoke a button click on an input element of type &#8220;submit&#8221; through javascript. Simply [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=27&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve run into a javascript problem a few times which -for a refreshing change &#8211; shows itself as Firefox not behaving as you might expect (&#8230; well Firefox together with ASP.NET at any rate).</p>
<p>The issue surfaces when you try and invoke a button click on an input element of type &#8220;submit&#8221; through javascript. Simply use <font face="Courier New">myButton.click()</font>you say? Well, unfortunately no. It can be the case that the click appears to work in terms of invoking any other javascript that might be attached to that event, but it actually does not invoke the postback to the server. The button works perfectly when use the mouse, but just doesn&#8217;t work with the <font face="Courier New">click()</font> method.</p>
<p>So the solution is to fake the button being clicked with the mouse when in firefox, and otherwise to just use what you&#8217;d expect:</p>
<p><font face="Courier New"><font color="#0000ff" size="2"><font color="#0000ff" size="2">if</font><font color="#000000"><font size="2"> (button.dispatchEvent)</font><font size="2"><br />
{<br />
</font></font>  var </font><font size="2">e = document.createEvent(</font><font color="#a31515" size="2">&#8220;MouseEvents&#8221;</font><font size="2">);<br />
</font><font size="2">  e.initEvent(<font color="#a31515" size="2">&#8220;click&#8221;</font><font size="2">, </font><font color="#0000ff" size="2">true</font><font size="2">, </font><font color="#0000ff" size="2">true</font><font size="2">);<br />
button.dispatchEvent(e);<br />
}<br />
<font color="#0000ff" size="2">else</font><br />
{<br />
button.click();<br />
}</font></font></font><font size="2"></font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pureblue.wordpress.com/27/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pureblue.wordpress.com/27/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pureblue.wordpress.com/27/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pureblue.wordpress.com/27/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pureblue.wordpress.com/27/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=27&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pureblue.co.nz/2008/02/14/clicking-a-button-in-javascript-doesnt-always-work-in-firefox/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e87832b33c29d5158683a1f55eff7700?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
		<item>
		<title>IE &#8211; &#8220;Postback when Enter pressed&#8221; bug!</title>
		<link>http://blog.pureblue.co.nz/2007/04/02/ie-postback-when-enter-pressed-bug/</link>
		<comments>http://blog.pureblue.co.nz/2007/04/02/ie-postback-when-enter-pressed-bug/#comments</comments>
		<pubDate>Mon, 02 Apr 2007 16:41:10 +0000</pubDate>
		<dc:creator>pureblue</dc:creator>
				<category><![CDATA[ASP.NET]]></category>
		<category><![CDATA[Gotcha's]]></category>

		<guid isPermaLink="false">http://pureblue.wordpress.com/2007/04/02/ie-postback-when-enter-pressed-bug/</guid>
		<description><![CDATA[I&#8217;ve just fixed a strange bug I was having when comparing a web page in IE and Firefox. The page simply had a single textbox, and a button. By default, in accordance with W3C standards, both browsers will post-back to the server when the user hits &#60;Enter&#62; from within the textbox. Just the behaviour I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=7&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve just fixed a strange bug I was having when comparing a web page in IE and Firefox. The page simply had a single textbox, and a button. By default, in accordance with W3C standards, both browsers will post-back to the server when the user hits &lt;Enter&gt; from within the textbox.</p>
<p>Just the behaviour I wanted, except that when the post-back occurs from IE, the button&#8217;s event handler does not get triggered on the server!! Very strange &#8230; but <a href="http://aspnet.4guysfromrolla.com/articles/060805-1.aspx"><span style="color:#000099;">this article</span></a> on <a href="http://aspnet.4guysfromrolla.com/"><span style="color:#000099;">4guysfromrolla.com</span></a> gives a great explanation.</p>
<p>Basically, IE does not post-back a fully serialised form if there is only one textbox on the page! The server does not know what triggered the post-back and so cannot call the correct server-side event handler. The workaround? &#8230; add another textbox to the form (but just make it hidden!).</p>
<p>This is true for IE6 and IE7 &#8230;</p>
<p><strong> Update 5 APR 2008: </strong>An example would be nice, so this is what I used&#8230;</p>
<p><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">&lt;<span style="color:#a31515;font-size:x-small;"><span style="color:#a31515;font-size:x-small;">asp</span></span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">:</span></span><span style="color:#a31515;font-size:x-small;"><span style="color:#a31515;font-size:x-small;">TextBox</span></span><span style="font-size:x-small;"> </span><span style="color:#ff0000;font-size:x-small;"><span style="color:#ff0000;font-size:x-small;">ID</span></span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">=&#8221;IEPostbackBugFix&#8221;</span></span><span style="font-size:x-small;"> </span><span style="color:#ff0000;font-size:x-small;"><span style="color:#ff0000;font-size:x-small;">runat</span></span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">=&#8221;server&#8221;</span></span><span style="font-size:x-small;"> </span><span style="color:#ff0000;font-size:x-small;"><span style="color:#ff0000;font-size:x-small;">style</span></span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">=&#8221;visibility:hidden;display:none;&#8221;</span></span><span style="font-size:x-small;"> </span><span style="color:#0000ff;font-size:x-small;"><span style="color:#0000ff;font-size:x-small;">/&gt;</span></span></span></span></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/pureblue.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/pureblue.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/pureblue.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/pureblue.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/pureblue.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=blog.pureblue.co.nz&amp;blog=2513886&amp;post=7&amp;subd=pureblue&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://blog.pureblue.co.nz/2007/04/02/ie-postback-when-enter-pressed-bug/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/1dc1bfb6258deeee46ec76b29047f84e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Matt</media:title>
		</media:content>
	</item>
	</channel>
</rss>
