<?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/"
	>

<channel>
	<title>Pavel Chuchuva &#187; Develop</title>
	<atom:link href="http://chuchuva.com/pavel/category/develop/feed/" rel="self" type="application/rss+xml" />
	<link>http://chuchuva.com/pavel</link>
	<description>Blog about software</description>
	<lastBuildDate>Mon, 07 May 2012 11:22:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Improving backup to Amazon S3</title>
		<link>http://chuchuva.com/pavel/2011/03/improving-backup-to-amazon-s3/</link>
		<comments>http://chuchuva.com/pavel/2011/03/improving-backup-to-amazon-s3/#comments</comments>
		<pubDate>Wed, 16 Mar 2011 20:08:39 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[s3]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=236</guid>
		<description><![CDATA[I use s3.exe command line utility to backup photos to Amazon Simple Storage (S3) and it works great. I have lots of photos to backup: 900,000 files in 4,000 folders. Obivously it is impractical to copy all files on every &#8230; <a href="http://chuchuva.com/pavel/2011/03/improving-backup-to-amazon-s3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I use <a href="http://s3.codeplex.com/">s3.exe command line</a> utility to backup photos to Amazon Simple Storage (S3) and it works great.</p>
<p>I have lots of photos to backup: 900,000 files in 4,000 folders.</p>
<p>Obivously it is impractical to copy all files on every backup &#8211; it will take forever. s3.exe has exact feature that I need:</p>
<blockquote><p>/sync is used with the put command and only uploads files that do not exist on S3 or have been modified since last being uploaded, based on the timestamp. It can be used alone or in conjunction with the /sub option for a fast incremental backup of a whole directory.</p></blockquote>
<p>Here&#8217;s command line that I use for backups:</p>
<pre><code>s3.exe put mybucket C:\photos\ /sub:withdelete /sync /acl:public-read /yes /nogui</code></pre>
<h1>Charges</h1>
<p>When I started using S3 however I was surpised with the bill from Amazon.</p>
<p>Let&#8217;s open source code to see how backup is done. Here are relevant bits:</p>
<pre><code class="prettyprint">foreach (string file in Sub.GetFiles(directory, filename, sub))
...
DateTime? lastModified = svc.getLastModified(bucket, key);
if (lastModified.HasValue &amp;&amp; lastModified.Value &gt; File.GetLastWriteTimeUtc(file))
{
Progress.reportProgress(key, 0, 0);
continue;
}
</code></pre>
<p>For each file s3.exe gets last modified date from the storage. If it is greater than last modified date of local file then no upload is performed.</p>
<p>Let&#8217;s do some calculations. To get last modified date s3.exe sends HEAD request. Amazon charges $0.01 per 10,000 HEAD requests. So I would end up paying $0.09 every time I perform backup. If I do it every day that&#8217;s $27 per month.</p>
<p>Let&#8217;s try to optimize it. How about this: for every local folder get the corresponding list of files in storage. Last modified date will be included in response. Now we&#8217;re going to issue about 4,000 LIST requests (1 for each folder). 1,000 LIST requests is $0.01 so that would be $0.04 in total. Or $1.20 per month &#8211; that&#8217;s saving ofÂ $25.80 &#8211; a big win <img src='http://chuchuva.com/pavel/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h1>Making the Patch</h1>
<p>I have created a patch by following steps from <a href="http://www.hanselman.com/blog/ExampleHowToContributeAPatchToAnOpenSourceProjectLikeDasBlog.aspx">Scott Hanselman&#8217;s blog post</a>.</p>
<p><img class="alignnone size-full wp-image-237" src="http://chuchuva.com/pavel/images/2011/03/patch1.png" alt="" width="350" height="229" /></p>
<p><img class="alignnone size-full wp-image-238" src="http://chuchuva.com/pavel/images/2011/03/patch2.png" alt="" width="409" height="388" /></p>
<p>I have submitted my patch to Codeplex, let&#8217;s see if project owner decides that it&#8217;s good enough to be applied.</p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2011/03/improving-backup-to-amazon-s3/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Converting .Net DateTime to JavaScript Date</title>
		<link>http://chuchuva.com/pavel/2010/10/converting-net-datetime-to-javascript-date/</link>
		<comments>http://chuchuva.com/pavel/2010/10/converting-net-datetime-to-javascript-date/#comments</comments>
		<pubDate>Tue, 19 Oct 2010 09:53:14 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=213</guid>
		<description><![CDATA[JavaScript Date constructor accepts number of milliseconds since Unix epoch (1 January 1970 00:00:00 UTC). Here&#8217;s C# extension method that converts .Net DateTime object to JavaScript date: public static class DateTimeJavaScript { private static readonly long DatetimeMinTimeTicks = (new DateTime(1970, &#8230; <a href="http://chuchuva.com/pavel/2010/10/converting-net-datetime-to-javascript-date/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>JavaScript <a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date">Date</a> constructor accepts number of milliseconds since Unix epoch (1 January 1970 00:00:00 UTC). Here&#8217;s C# extension method that converts .Net DateTime object to JavaScript date:</p>
<pre><code class="prettyprint">public static class DateTimeJavaScript
{
   private static readonly long DatetimeMinTimeTicks =
      (new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc)).Ticks;

   public static long ToJavaScriptMilliseconds(this DateTime dt)
   {
      return (long)((dt.ToUniversalTime().Ticks - DatetimeMinTimeTicks) / 10000);
   }
}
</code></pre>
<p>Usage:</p>
<pre><code class="prettyprint">var dt = new Date(&lt;%= DateTime.Today.ToJavaScriptMilliseconds() %&gt;);
alert(dt);
</code></pre>
<h3>Reference</h3>
<p><a href="http://stackoverflow.com/questions/290227/java-system-currenttimemillis-equivalent-in-c">Java System.currentTimeMillis() equivalent in C#</a></p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/10/converting-net-datetime-to-javascript-date/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to enable detailed error information for IIS and ASP.NET</title>
		<link>http://chuchuva.com/pavel/2010/08/how-to-enable-detailed-error-information-for-iis-and-asp-net/</link>
		<comments>http://chuchuva.com/pavel/2010/08/how-to-enable-detailed-error-information-for-iis-and-asp-net/#comments</comments>
		<pubDate>Wed, 18 Aug 2010 01:09:27 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[iis]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=197</guid>
		<description><![CDATA[By default, IIS and ASP.NET hide detailed error information to prevent revealing sensitive information about your web application: Sometimes you need to see error details (think shared hosting). Add these entries to your web.config file to disable generic errors: &#60;configuration&#62; &#8230; <a href="http://chuchuva.com/pavel/2010/08/how-to-enable-detailed-error-information-for-iis-and-asp-net/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>By default, IIS and ASP.NET hide detailed error information to prevent revealing sensitive information about your web application:<br />
<img src="http://chuchuva.com/pavel/images/2010/08/iis-generic-error.png" alt="IIS generic error" title="" width="502" height="343" class="alignnone size-full wp-image-201" /></p>
<p><img src="http://chuchuva.com/pavel/images/2010/08/asp-net-generic-error.png" alt="ASP.NET generic error" title="" width="715" height="482" class="alignnone size-full wp-image-202" /></p>
<p>Sometimes you need to see error details (think shared hosting). Add these entries to your web.config file to disable generic errors:</p>
<pre><code class="prettyprint">&lt;configuration&gt;
  &lt;system.web&gt;
    &lt;customErrors mode="Off" /&gt;
  &lt;/system.web&gt;

  &lt;system.webServer&gt;
    &lt;httpErrors errorMode="Detailed" /&gt;
  &lt;/system.webServer&gt;
&lt;/configuration&gt;
</code></pre>
<p><strong>Resources</strong></p>
<ul>
<li><a href="http://learn.iis.net/page.aspx/267/how-to-use-http-detailed-errors-in-iis-70/">How to Use HTTP Detailed Errors in IIS 7.0</a></li>
<li><a href="http://blogs.iis.net/ksingla/archive/2008/02/18/what-to-expect-from-iis7-custom-error-module.aspx">What to expect from IIS7 custom error module</a></li>
<li><a href="http://www.west-wind.com/weblog/posts/745738.aspx">IIS 7 Error Pages taking over 500 Errors</a></li>
<li><a href="http://stackoverflow.com/questions/434272/iis7-overrides-customerrors-when-setting-response-statuscode">IIS7 Overrides customErrors when setting Response.StatusCode?</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/08/how-to-enable-detailed-error-information-for-iis-and-asp-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>jQuery BBQ plugin and Internet Explorer 7</title>
		<link>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/</link>
		<comments>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 10:40:06 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=174</guid>
		<description><![CDATA[Remember the problem with jQuery BBQ plugin in Internet Explorer 7? It&#8217;s not really a problem, just a minor glitch but let&#8217;s fix it anyway. Steps to reproduce: Open BBQ demo in Internet Explorer Click Next button few times Open &#8230; <a href="http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Remember the problem with jQuery BBQ plugin in Internet Explorer 7? It&#8217;s not really a problem, just a minor glitch but let&#8217;s fix it anyway.</p>
<p>Steps to reproduce:</p>
<ol>
<li>Open <a href="http://chuchuva.com/demo/jquery-bbq/">BBQ demo</a> in Internet Explorer</li>
<li>Click Next button few times</li>
<li>Open history menu</li>
</ol>
<p>Observe:<br />
<img class="alignnone size-full wp-image-170" src="http://chuchuva.com/pavel/images/2010/04/bbq-ie7.png" alt="" width="336" height="231" /></p>
<p>No page titles, just URLs. Definitely it would be nice to see photo numbers there.</p>
<p>First, let&#8217;s see how <a href="http://www.asual.com/jquery/address/">Asual jQuery Address</a> fix this problem:</p>
<pre><code class="prettyprint">_title = _d.title = value;
if (_juststart &#038;&#038; _frame &#038;&#038; _frame.contentWindow &#038;&#038;
    _frame.contentWindow.document) {
    _frame.contentWindow.document.title = value;
    _juststart = FALSE;
}
</code></pre>
<p>Aha! For IE7 you need to set title of the hidden iframe in addition to setting document title. So this is how you set page title:</p>
<pre><code class="prettyprint">document.title = "New title";
var iframe = $("iframe:hidden");
if (iframe.length > 0 &#038;&#038; iframe[0].contentWindow &#038;&#038; iframe[0].contentWindow.document)
  iframe[0].contentWindow.document.title = "New title";
</code></pre>
<p><a href="http://chuchuva.com/demo/jquery-bbq/fix-for-ie7.html">Updated demo</a> should work correctly in Internet Explorer 7.</p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/jquery-bbq-plugin-and-internet-explorer-7/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jQuery BBQ plugin for photo gallery</title>
		<link>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/</link>
		<comments>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 11:41:59 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=167</guid>
		<description><![CDATA[Click here to view demo Let&#8217;s take previous demo and use jQuery BBQ plugin instead. Our goal is Ajax photo gallery that supports browser&#8217;s back button. We will display numbers instead of actual photos for now. $(function () { $(window).bind('hashchange', &#8230; <a href="http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://chuchuva.com/demo/jquery-bbq/">Click here to view demo</a></p>
<p>Let&#8217;s take <a href="http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/">previous demo</a> and use <a href="http://benalman.com/projects/jquery-bbq-plugin/">jQuery BBQ plugin</a> instead. Our goal is Ajax photo gallery that supports browser&#8217;s back button. We will display numbers instead of actual photos for now.</p>
<pre><code class="prettyprint">$(function ()
{
  $(window).bind('hashchange', function(e) {
    var i = parseInt(e.fragment, 10);
    if (!isNaN(i))
      switchTo(i);
  });
  $(window).trigger('hashchange');
});

function switchTo(i)
{
  if ($("#number").text() == i)
    return;
  $("#number").text(i);
  document.title = i;
  if (i > 1)
    $("#lnk_prev").attr("href", "#" + (i - 1)).removeClass("disabled");
  else
    $("#lnk_prev").removeAttr("href").addClass("disabled");
  if (i < 20)
    $("#lnk_next").attr("href", "#" + (i + 1)).removeClass("disabled");
  else
    $("#lnk_next").removeAttr("href").addClass("disabled");
}
</code></pre>
<p>Instead of handling click event we modify href attribute of the links. BBQ will fire hashchange event whenever we "navigate" to a new page. No need to prevent default processing â€“ simple!</p>
<p>One gotcha to watch out for is changing page title. If you take naive approach and simply use document.title (like I did) to set page title you won't see your titles in the history menu in Internet Explorer 7:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/bbq-ie7.png" alt="" width="336" height="231" class="alignnone size-full wp-image-170" /></p>
<p>Compare with Internet Explorer 8:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/bbq-ie8.png" alt="" width="336" height="232" class="alignnone size-full wp-image-171" /></p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/using-jquery-bbq-plugin-for-photo-gallery/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Asual jQuery Address plugin for photo gallery</title>
		<link>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/</link>
		<comments>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/#comments</comments>
		<pubDate>Fri, 09 Apr 2010 10:42:20 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>
		<category><![CDATA[jquery]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=151</guid>
		<description><![CDATA[Click here to view demo Let&#8217;s say you want to build photo gallery. Something like this: You want to open next and previous photos without page reload, using Ajax. One problem with this is that browser&#8217;s back button stops working. &#8230; <a href="http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p><a href="http://chuchuva.com/demo/asual-jquery-address/">Click here to view demo</a></p>
<p>Let&#8217;s say you want to build photo gallery. Something like this:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/gallery-mockup.gif" alt="" width="270" height="251" class="alignnone size-full wp-image-153" /></p>
<p>You want to open next and previous photos without page reload, using Ajax. One problem with this is that browser&#8217;s back button stops working. Fortunately, it&#8217;s easy to fix with <a href="http://www.asual.com/jquery/address/">jQuery Address plugin</a> from Asual. I tried using this plugin and it worked very well. I&#8217;ve put together a simple <a href="http://chuchuva.com/demo/asual-jquery-address/">demo</a>.</p>
<p>For simplicity, let&#8217;s display just a number instead of actual photo:<br />
<img src="http://chuchuva.com/pavel/images/2010/04/gallery-mockup2.gif" alt="" width="261" height="216" class="alignnone size-full wp-image-154" /></p>
<p>Every time you click right arrow the number increases; left arrow decrements the number by one. Simple! Back and forward buttons should work. Also, it would be nice to have different titles in the history:</p>
<p><img src="http://chuchuva.com/pavel/images/2010/04/browser-history.png" alt="" width="181" height="173" class="alignnone size-full wp-image-155" /></p>
<p>The code:</p>
<pre><code class="prettyprint">$(function ()
{
  $.address.strict(false);
  $.address.externalChange(function(e)
  {
    switchTo(e.value);
  });

  $("#lnk_prev").click(function(e)
  {
    e.preventDefault();
    var i = $("#number").text() * 1 - 1;
    switchTo(i);
    $.address.value(i);
  });

  $("#lnk_next").click(function(e)
  {
    e.preventDefault();
    var i = $("#number").text() * 1 + 1;
    switchTo(i);
    $.address.value(i);
  });
});

function switchTo(i)
{
  $("#number").text(i);
  $.address.title(i);
}
</code></pre>
<p>The magic happens in click handler. $.address.value method changes page address and adds browser history point. You need to cancel navigation by calling e.preventDefault() — otherwise browser would follow the link and two history entries would get created.</p>
<p><a href="http://chuchuva.com/demo/asual-jquery-address/"><img src="http://chuchuva.com/pavel/images/2010/04/gallery-demo.png" alt="" width="499" height="450" class="alignnone size-full wp-image-158" /></a></p>
<p>Note that you need to disable plugin&#8217;s strict option, otherwise it would add slash symbol immediately after hash symbol, like this: #/11.</p>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2010/04/using-asual-jquery-address-plugin-for-photo-gallery/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to use ClientScriptManager.RegisterForEventValidation method</title>
		<link>http://chuchuva.com/pavel/2009/12/how-to-use-clientscriptmanager-registerforeventvalidation-method/</link>
		<comments>http://chuchuva.com/pavel/2009/12/how-to-use-clientscriptmanager-registerforeventvalidation-method/#comments</comments>
		<pubDate>Wed, 09 Dec 2009 10:21:00 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=54</guid>
		<description><![CDATA[Have you ever encountered this error: Invalid postback or callback argument. Â Event validation is enabled using &#60;pages enableEventValidation=&#8221;true&#8221;/&#62; in configuration or &#60;%@ Page EnableEventValidation=&#8221;true&#8221; %&#62; in a page. Â For security purposes, this feature verifies that arguments to postback or callback &#8230; <a href="http://chuchuva.com/pavel/2009/12/how-to-use-clientscriptmanager-registerforeventvalidation-method/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Have you ever encountered this error:</p>
<blockquote><p>Invalid postback or callback argument. Â Event validation is enabled using &lt;pages enableEventValidation=&#8221;true&#8221;/&gt; in configuration or &lt;%@ Page EnableEventValidation=&#8221;true&#8221; %&gt; in a page. Â For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. Â If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.</p></blockquote>
<p>That&#8217;s pretty long error message. I get this exception if I add items to drop-down control from JavaScript. The question is how to use ClientScriptManager.RegisterForEventValidation method?</p>
<p>First, let&#8217;s reproduce the problem. Create a new website and copy/paste this code:</p>
<pre><code class="prettyprint">&lt;asp:DropDownList ID="dd" runat="server"&gt;
  &lt;asp:ListItem&gt;One&lt;/asp:ListItem&gt;
  &lt;asp:ListItem&gt;Two&lt;/asp:ListItem&gt;
&lt;/asp:DropDownList&gt;
&lt;asp:Button ID="Button1" runat="server" Text="Test" /&gt;

&lt;script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"
  type="text/javascript"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;
  $(function()
  {
    $("#&lt;%= dd.ClientID %&gt;").append($("&lt;option /&gt;")
      .val(3)
      .text("Three!"));
  });
&lt;/script&gt;</code></pre>
<p>If you select option &#8220;Three&#8221; sure enough, exception is thrown. To prevent it you need to supply all possible values for drop-down control:</p>
<pre class="prettyprint"><code>protected override void Render(HtmlTextWriter writer)
{
  Page.ClientScript.RegisterForEventValidation(dd.UniqueID, "3");
  Page.ClientScript.RegisterForEventValidation(dd.UniqueID, "4");
  Page.ClientScript.RegisterForEventValidation(dd.UniqueID, "11");
  // and so on
  base.Render(writer);
}
</code></pre>
<p>The exception is fixed but server variable for drop-down control is useless &#8211; it has no idea that you&#8217;ve added new item so dd.SelectedValue will give One, not 3. You need to read POST variable directly instead, like this:</p>
<pre class="prettyprint"><code>protected void Page_Load(object sender, EventArgs e)
{
   if (IsPostBack)
      Response.Write(Request.Form[dd.UniqueID]);
}
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2009/12/how-to-use-clientscriptmanager-registerforeventvalidation-method/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>How to view whitespaces in Emacs</title>
		<link>http://chuchuva.com/pavel/2009/09/how-to-view-whitespaces-in-emacs/</link>
		<comments>http://chuchuva.com/pavel/2009/09/how-to-view-whitespaces-in-emacs/#comments</comments>
		<pubDate>Wed, 16 Sep 2009 08:48:47 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/?p=49</guid>
		<description><![CDATA[Here&#8217;s how you can view whitespaces in Emacs: M-x whitespace-mode RET By default, Emacs uses bright colours to highlight whitespaces that are in wrong place (in Emacs&#8217; opinion): To disable colouring add the following to your .emacs file: ; disable &#8230; <a href="http://chuchuva.com/pavel/2009/09/how-to-view-whitespaces-in-emacs/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Here&#8217;s how you can view whitespaces in Emacs:</p>
<pre>M-x whitespace-mode RET</pre>
<p>By default, Emacs uses bright colours to highlight whitespaces that are in wrong place (in Emacs&#8217; opinion):<br />
<img class="alignnone size-full wp-image-50" src="http://chuchuva.com/pavel/images/2009/09/emacs-whitespaces-colour.png" alt="" width="320" height="200" /></p>
<p>To disable colouring add the following to your .emacs file:</p>
<pre>; disable colours in whitespace-mode
(setq whitespace-style '(space-mark tab-mark))</pre>
<p>Now it&#8217;s much better:</p>
<p><img class="alignnone size-full wp-image-51" src="http://chuchuva.com/pavel/images/2009/09/emacs-whitespaces.png" alt="" width="320" height="200" /></p>
<p>I assign showing white spaces to Ctrl+Shift+8 to mimick Visual Studio behaviour:</p>
<pre>(global-set-key (kbd "C-*") 'whitespace-mode)</pre>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2009/09/how-to-view-whitespaces-in-emacs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to insert new GUID with one key press</title>
		<link>http://chuchuva.com/pavel/2008/03/how-to-insert-new-guid-with-one-key-press/</link>
		<comments>http://chuchuva.com/pavel/2008/03/how-to-insert-new-guid-with-one-key-press/#comments</comments>
		<pubDate>Thu, 27 Mar 2008 06:09:37 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/2008/03/how-to-insert-new-guid-with-one-key-press/</guid>
		<description><![CDATA[When I work with WiX source code I need to create lots of GUIDs. In my Visual Studio 2005 editor all I need to do is to press Alt+G and new GUID magically appears at the cursor. Achieving this is &#8230; <a href="http://chuchuva.com/pavel/2008/03/how-to-insert-new-guid-with-one-key-press/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>When I work with <a href="http://wix.sourceforge.net/">WiX</a> source code I need to create lots of GUIDs. In my Visual Studio 2005 editor all I need to do is to press Alt+G and new GUID magically appears at the cursor. Achieving this is very easy:</p>
<ol>
<li> Open Macros IDE by selecting Tools | Macros | Macros IDE.</li>
<li>Create new macro:</li>
<p style="margin: 0.3em 0pt 0pt"><span style="font-size: 10pt">Public</span><span style="font-size: 10pt"> <span style="color: blue">Sub</span> InsertGuid()</span></p>
<p style="margin: 0pt"><span style="font-size: 10pt">    DTE.ActiveDocument.Selection.Text = Guid.NewGuid().ToString()</span></p>
<p style="margin: 0pt 0pt 0.3em"><span style="font-size: 10pt">End</span><span style="font-size: 10pt"> <span style="color: blue">Sub<o:p></o:p></span></span></p>
<li>Bind new macro to <strong>Alt+G</strong> keyboard shortcut. Open Options dialog, select Environment, then Keyboard on the left. Type &#8220;<strong>InsertGuid</strong>&#8221; to locate the macro you just created. Assign Alt+G to it.<br />
<img src="http://chuchuva.com/pavel/images/2008/03/vs-keyboard.gif" /><br />
Fortunately, no standard command is assigned to Alt+G by default.</li>
</ol>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2008/03/how-to-insert-new-guid-with-one-key-press/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to automate Adobe InDesign CS3</title>
		<link>http://chuchuva.com/pavel/2008/02/how-to-automate-adobe-indesign-cs3/</link>
		<comments>http://chuchuva.com/pavel/2008/02/how-to-automate-adobe-indesign-cs3/#comments</comments>
		<pubDate>Thu, 28 Feb 2008 04:30:17 +0000</pubDate>
		<dc:creator>Pavel Chuchuva</dc:creator>
				<category><![CDATA[Develop]]></category>

		<guid isPermaLink="false">http://chuchuva.com/pavel/2008/02/how-to-automate-adobe-indesign-cs3/</guid>
		<description><![CDATA[1. Locate Resources for Visual Basic.tlb in C:\Documents and Settings\All Users\Application Data\Adobe\InDesign\Version 5.0\Scripting Support\5.0 folder. 2. Open command prompt and execute: TlbImp.exe "Resources for Visual Basic.tlb" /out:Interop.InDesign.dll TlbImp.exe is located in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin folder on my machine. &#8230; <a href="http://chuchuva.com/pavel/2008/02/how-to-automate-adobe-indesign-cs3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>1. Locate Resources for Visual Basic.tlb in C:\Documents and Settings\All Users\Application Data\Adobe\InDesign\Version 5.0\Scripting Support\5.0 folder.</p>
<p>2. Open command prompt and execute:</p>
<pre><code>TlbImp.exe "Resources for Visual Basic.tlb" /out:Interop.InDesign.dll</code></pre>
<p>TlbImp.exe is located in C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin folder on my machine. This will generate Interop.InDesign.dll file. This is an interop assembly.</p>
<p>3. Add reference to Interop.InDesign.dll to your project.</p>
<p>4. Use this code:</p>
<pre class="prettyprint"><code>using System;
using InDesign;

namespace HelloInDesign
{
   class Program
   {
      static void Main(string[] args)
      {
         object missing = Type.Missing;
         Type type = Type.GetTypeFromProgID("InDesign.Application.CS3");
         if (type == null)
         {
            throw new Exception("Adobe InDesign CS3 is not installed");
         }
         _Application app = (_Application)Activator.CreateInstance(type);
         Document document = (Document)app.Documents.Add(true, missing);
         Page page = (Page)document.Pages[1];
         TextFrame textFrame = page.TextFrames.Add(missing,
            idLocationOptions.idUnknown, missing);
         textFrame.GeometricBounds = new string[] { "6p", "6p", "24p", "24p" };
         textFrame.Contents = "Hello from .Net!";
      }
   }
}</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://chuchuva.com/pavel/2008/02/how-to-automate-adobe-indesign-cs3/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

