<?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>PGS Software &#187; tips &amp; tricks</title>
	<atom:link href="http://www.pgs-soft.com/tag/tips-tricks/feed" rel="self" type="application/rss+xml" />
	<link>http://www.pgs-soft.com</link>
	<description>Nearshore Outsourcing IT Company - Offshore Development</description>
	<lastBuildDate>Fri, 30 Jul 2010 09:54:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>ValidatorCalloutExtender and server validation in ASP.NET</title>
		<link>http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html</link>
		<comments>http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html#comments</comments>
		<pubDate>Mon, 17 May 2010 07:00:24 +0000</pubDate>
		<dc:creator>Waldemar Mękal</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=3006</guid>
		<description><![CDATA[The story behind is that we had an application which heavily used ValidatorCalloutExtender for displaying validation errors. Everything was working great till we had to validate date in non-english culture. We used CompareValidator for validating date (&#8220;DataTypeCheck&#8221; operator). Then, strange thing happened &#8211; form wasn&#8217;t saved, but no validation message was shown. After further digging [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fvalidatorcalloutextender-and-server-validation-in-asp-net.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fvalidatorcalloutextender-and-server-validation-in-asp-net.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>The story behind is that we had an application which heavily used ValidatorCalloutExtender for displaying validation errors. Everything was working great till we had to validate date in non-english culture. We used CompareValidator for validating date (&#8220;DataTypeCheck&#8221; operator). Then, strange thing happened &#8211; form wasn&#8217;t saved, but no validation message was shown. After further digging I discovered that CompareValidator runs only on server side for validating date in non-english culture and ValidatorCalloutExtender does not show after post back as it is written on its <a href="http://www.asp.net/ajax/ajaxcontroltoolkit/samples/ValidatorCallout/ValidatorCallout.aspx" target="_blank">page</a>:</p>
<blockquote><p>The callouts do not currently display automatically after a server  post-back and will only work for             custom validators which utilize client-side validation. Even  after a post-back the callout will             display when the form is re-validated when a postback is  attempted again.</p></blockquote>
<p>To not rewrite validation (displaying validation messages) in whole application we came to the following solution. Validation must be done on client side to show ValidatorCalloutExtender, so we used CustomValidator which perform date validation on server side  and use ajax on client side to call the same method on server side.</p>
<p>Simplified markup is as follows.</p>
<pre>&lt;asp:TextBox ID="TbDateOfBirth" runat="server" /&gt;</pre>
<pre>&lt;asp:CustomValidator ID="DateValidator" runat="server"
  ControlToValidate="TbDateOfBirth"
  SetFocusOnError="True" Display="None"
  ClientValidationFunction="DateValidator_ClientValidate"
  OnServerValidate="DateValidator_ServerValidate"
  meta:resourcekey="DateValidatorResource1" /&gt;

&lt;ajaxToolkit:ValidatorCalloutExtender runat="server"
  ID="DateValidatorE"
  TargetControlID="DateValidator" /&gt;
</pre>
<p>Javascript function is below. We used jquery, because using MS AJAX you can&#8217;t do synchronous call and we need that to return validation result immediately.</p>
<pre>function DateValidator_ClientValidate(source,
                                      clientside_arguments) {
  clientside_arguments.IsValid = false;

  jQuery.ajax({
    type: "POST",
    async: false,
    url: "Validation.aspx/IsDateValid",
    data: "{date: '" + clientside_arguments.Value + "'}",
    contentType: "application/json; charset=utf-8",
    dataType: "json",
    success: function(msg) {
     clientside_arguments.IsValid = msg.d;
    },
    error: function(msg) {
      clientside_arguments.IsValid = false;
    }
  });

  return clientside_arguments.IsValid;
}</pre>
<p>Server side method within Validation.aspx page:</p>
<pre>[WebMethod]
public static bool IsDateValid(string date)
{
  SetupCulture();//to set correct culture for dates

  try
  {
    DateTime.Parse(date, Thread.CurrentThread.CurrentCulture);
    return true;
  }
  catch( Exception ex )
  {
    return false;
  }
}
</pre>
<p>And server side validation method for CustomValidator.</p>
<pre>protected void DateValidator_ServerValidate(object sender,
                                 ServerValidateEventArgs e)
{
  e.IsValid = Validation.IsDateValid(e.Value);
}
</pre>
<p>So, basically that&#8217;s it. Maybe this is not the most elegant solution, but it&#8217;s simple and works.</p>
<p>Hope it helps.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html">http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/hosting-asp-net-application-on-a-shared-server.html' rel='bookmark' title='Permanent Link: Hosting ASP.Net application on a shared server'>Hosting ASP.Net application on a shared server</a></li>
<li><a href='http://www.pgs-soft.com/introduction-to-xval.html' rel='bookmark' title='Permanent Link: Introduction to xVal'>Introduction to xVal</a></li>
<li><a href='http://www.pgs-soft.com/asp-net-session-mockup.html' rel='bookmark' title='Permanent Link: ASP.NET session mockup'>ASP.NET session mockup</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing AWStats on IIS 7.0 &#8211; time-taken extra section</title>
		<link>http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html</link>
		<comments>http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html#comments</comments>
		<pubDate>Thu, 04 Mar 2010 13:43:46 +0000</pubDate>
		<dc:creator>mstankala</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[aspx]]></category>
		<category><![CDATA[AWStats]]></category>
		<category><![CDATA[IIS 6.0]]></category>
		<category><![CDATA[IIS 7.0]]></category>
		<category><![CDATA[logfile time-taken field]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=3462</guid>
		<description><![CDATA[AWStats is an open-source Log analyzer than can be easily configured to work with IIS logs. My AWStats configuration for IIS7 is based on a great instruction written by Simon Schofield Installing AWStats on IIS 6.0 (Including IIS 5.1) &#8211; Revision 3.0. But &#8220;out of the box&#8221; AWStats doesn&#8217;t provide any statistics for the time-taken [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Finstalling-awstats-on-iis-7-0-time-taken-extra-section.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Finstalling-awstats-on-iis-7-0-time-taken-extra-section.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><img class="alignright size-full wp-image-3464" src="http://www.pgs-soft.com/wp-content/uploads/2010/03/AWStats_IIS7.jpg" alt="" width="415" /></p>
<p><a href="http://awstats.sourceforge.net/#DOWNLOAD">AWStats</a> is an open-source Log analyzer than can be easily configured to work with IIS logs.</p>
<p>My AWStats configuration for IIS7 is based on a great instruction written by Simon Schofield <a href="http://www.ihsen.com/support/InstallingAWStatsOnIIS6.pdf">Installing AWStats on IIS 6.0</a> (Including IIS 5.1) &#8211; Revision 3.0.</p>
<p>But &#8220;out of the box&#8221; AWStats doesn&#8217;t provide any statistics for the <strong>time-taken</strong> IIS logfile field. It also can&#8217;t be configured, using the provided <a href="http://awstats.sourceforge.net/docs/awstats_extra.html">Extra Section</a> feature.</p>
<p>But it can be &#8220;easily&#8221; added, by updating the core <strong>awstat.pl</strong> configuration file.</p>
<p>Find below my updated instruction <strong>how-to install AWStats on IIS 7.0</strong> and <strong>include in the Extra Section the Time-taken statistics</strong>, which displays the <strong>average of time-taken</strong> to display a specific <strong>ASPX page</strong>:</p>
<p><strong>INSTRUCTION</strong> for AWStats 6.95 (build 1.943) :<br />
<a href="http://www.pgs-soft.com/wp-content/uploads/2010/03/InstallingAWStatsOnIIS6_IIS7.pdf">Installing AWStats on IIS 7.0 and IIS 6.0 including time-taken statistics</a><br />
<strong>DOWNLOAD awstats.pl</strong>:<br />
<a href='http://www.pgs-soft.com/wp-content/uploads/2010/03/awstats.zip'>Updated awstats.pl configuration file</a>, that include the IIS <strong>time-taken</strong> statistics.</p>
<p>***********************************************<br />
<strong>A very short description:</strong></p>
<p>First in the <strong>LogFormat</strong> string a new extra parameter was specified:<br />
<code>LogFormat="%time2 %method %url %other %logname %host %other %ua %query %virtualname %code %bytesd <strong>%extra1</strong>"</code></p>
<p>In the awstats.pl file the lines of code responsible for counting the page hits, were replaced by computing the average of time-taken to open a webpage &#8211; new variable was introduced for that. Additionally the web-report(general and detailed) column title was changed to &#8220;Avg Time Taken[ms]&#8220;:<br />
<a href="http://www.pgs-soft.com/wp-content/uploads/2010/03/time-taken-1.jpg"><img src="http://www.pgs-soft.com/wp-content/uploads/2010/03/time-taken-1.jpg" alt="" width="505" class="alignright size-full wp-image-3483" /></a></p>
<p>An <strong> example of the AWStats time-taken statistics for IIS 7.0</strong>:<br />
<a href="http://www.pgs-soft.com/wp-content/uploads/2010/03/AWStats_IIS7_time-taken_section.jpg"><img class="alignright size-full wp-image-3477" src="http://www.pgs-soft.com/wp-content/uploads/2010/03/AWStats_IIS7_time-taken_section.jpg" alt="" width="505" /></a></p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html#comments">Comments (4)</a> - originally posted here <a href="http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html">http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html' rel='bookmark' title='Permanent Link: Web Deployment Project &#8211; Visual Studio 2008 Add-in'>Web Deployment Project &#8211; Visual Studio 2008 Add-in</a></li>
<li><a href='http://www.pgs-soft.com/hosting-asp-net-application-on-a-shared-server.html' rel='bookmark' title='Permanent Link: Hosting ASP.Net application on a shared server'>Hosting ASP.Net application on a shared server</a></li>
<li><a href='http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html' rel='bookmark' title='Permanent Link: Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException'>Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/installing-awstats-on-iis-7-0-time-taken-extra-section.html/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Web Deployment Project &#8211; Visual Studio 2008 Add-in</title>
		<link>http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html</link>
		<comments>http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html#comments</comments>
		<pubDate>Wed, 10 Feb 2010 10:50:40 +0000</pubDate>
		<dc:creator>mstankala</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[AfterBuild]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[aspx]]></category>
		<category><![CDATA[BeforeBuild]]></category>
		<category><![CDATA[merging assemblies]]></category>
		<category><![CDATA[pluggable configuration files]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips & tricks]]></category>
		<category><![CDATA[visual studio]]></category>
		<category><![CDATA[WebDeploymentProject]]></category>
		<category><![CDATA[WebDeploymentSetup]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=3174</guid>
		<description><![CDATA[Visual Studio Web Deployment Projects, provide additional functionality to build and deploy Web sites and Web applications in Visual Studio 2008. This Add-In can be downloaded from Microsoft website: Web Deployment Projects. The Visual Studio built-in &#8220;Copy Website&#8221; and &#8220;Publish Website&#8221; options are lacking of flexibility. Web Deployment Projects provides additional functionality for example: - [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fwebdeploymentsetup-visual-studio-2008-add-in.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fwebdeploymentsetup-visual-studio-2008-add-in.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.pgs-soft.com/wp-content/uploads/2010/02/webdeploymentproject.jpg"><img src="http://www.pgs-soft.com/wp-content/uploads/2010/02/webdeploymentproject.jpg" alt="webdeploymentproject" width="420" class="aligncenter size-full wp-image-3176" /></a></p>
<p>Visual Studio Web Deployment Projects, provide additional functionality to build and deploy Web sites and Web applications in Visual Studio 2008. This Add-In can be downloaded from Microsoft website: <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&amp;displaylang=en">Web Deployment Projects</a>.</p>
<p>The Visual Studio built-in &#8220;Copy Website&#8221; and &#8220;Publish Website&#8221; options are lacking of flexibility. Web Deployment Projects provides additional functionality for example:<br />
- merging assemblies (from context menu)<br />
- the ability to create pluggable configuration files (from context menu)<br />
- exclude files and folders (*.wdproj file in deployment project)</p>
<p><strong>When merging assemblies</strong> you can specify to get only <strong>1 result DLL</strong>, instead of multiple when using &#8220;Publish web site&#8221;.<br />
Second thing is, that you can <strong>define a strong name of result DLL</strong> file which means, that it will be easier to updates the web site on the webserver &#8211; just replacing the DLL, instead of deleting all assemblies with *.compiled XMLs and copying new ones (can be hundreds). So you don&#8217;t have to carry about the &#8220;strange&#8221; assemblies file names (with the hash code varying) like: App_Web_0375kxso.dll, etc.</p>
<p>Ability to create <strong>pluggable configuration files</strong> allows you to specify independent files, that store the contents of a particular configuration section independently, based on solution configurations. That means for example, that the Web.config  section will include <strong>different database connectionString for Debug and Release</strong>, or any other user specified solution configuration.</p>
<p>You can also <strong>exclude files and folders</strong> that shouldn&#8217;t be part of the release, e.g: reports, uploaded files, etc.</p>
<p>Finally the *.wdproj configuration file has a MSBuild syntax, so you can specify there whatever you want. <strong>Out of the box</strong> there are 4 build process sections: <strong>BeforeBuild, BeforeMerge, AfterMerge, AfterBuild</strong>, where you can specify your tasks.</p>
<p><strong>The detailed description of the Web Deployment Projects</strong> can be found <a href="http://msdn.microsoft.com/en-us/magazine/cc163448.aspx">HERE</a>.<br />
*********************************************************<br />
Find below some of my *.<strong>wdproj configuration examples</strong>:</p>
<p><strong>Exclude directory</strong>:<br />
<code style="font-size:11px">&lt;ItemGroup&gt;<br />
&lt;ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\_svn\**" /&gt;<br />
&lt;ExcludeFromBuild Include="$(SourceWebPhysicalPath)\**\.svn\**" /&gt;<br />
&lt;/ItemGroup&gt;<br />
</code></p>
<p><strong>Exclude directory except specified file</strong>:<br />
<code style="font-size:11px">&lt;ItemGroup&gt;<br />
&lt;ExcludeFromBuild Include="$(SourceWebPhysicalPath)\ChartImages\**\*.*" Exclude="$(SourceWebPhysicalPath)\ChartImages\**\place.holder" /&gt;<br />
&lt;/ItemGroup&gt;<br />
</code></p>
<p><strong>Minimize (shrink) JavaScript files using Microsoft Ajax Minifier</strong> <a href="http://gasior.net.pl/2009/11/30/kurczymy-skrypty-javascript-microsoft-ajax-minifier/">(based on Łukasz Gąsior blog</a>):<br />
<code style="text-align:left;font-size:9px">&lt;Import Project="$(MSBuildExtensionsPath)\Microsoft\MicrosoftAjax\AjaxMin.tasks" /&gt;<br />
&lt;Target Name="AfterBuild"&gt;<br />
&lt;ItemGroup&gt;<br />
&lt;!-- Create the list of JS files to minimize. Exclude *.min.js files, e.g. jquery-xxx.min.js --&gt;<br />
 &lt;JsFilesDevelopment Include="$(OutputPath)\**\*.js" Exclude="$(OutputPath)\**\*.min.js" /&gt;<br />
&lt;/ItemGroup&gt;<br />
&lt;!-- Minimize the JavaScript using AjaxMin  --&gt;<br />
&lt;AjaxMin SourceFiles="@(JsFilesDevelopment)" SourceExtensionPattern="\.js$" TargetExtension=".js" LocalRenaming="CrunchAll" /&gt;<br />
&lt;/Target&gt;<br />
</code></p>
<p>*********************************************************</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html#comments">Comments (1)</a> - originally posted here <a href="http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html">http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/manycore-and-the-microsoft-net-framework-4-a-match-made-in-microsoft-visual-studio-2010.html' rel='bookmark' title='Permanent Link: Manycore and the Microsoft .NET Framework 4: A Match Made in Microsoft Visual Studio 2010'>Manycore and the Microsoft .NET Framework 4: A Match Made in Microsoft Visual Studio 2010</a></li>
<li><a href='http://www.pgs-soft.com/visual-studio-2010-net-4-0-beta-1.html' rel='bookmark' title='Permanent Link: Visual Studio 2010 .NET 4.0 (Beta 1)'>Visual Studio 2010 .NET 4.0 (Beta 1)</a></li>
<li><a href='http://www.pgs-soft.com/visual-studio-2010-beta-2-and-ajax-library.html' rel='bookmark' title='Permanent Link: Visual Studio 2010 Beta 2 and Ajax Library'>Visual Studio 2010 Beta 2 and Ajax Library</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/webdeploymentsetup-visual-studio-2008-add-in.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>LinqToSql and comparisons with null</title>
		<link>http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html</link>
		<comments>http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html#comments</comments>
		<pubDate>Mon, 08 Feb 2010 07:35:24 +0000</pubDate>
		<dc:creator>Waldemar Mękal</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[.net]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=3146</guid>
		<description><![CDATA[Recently, I have been very surprised by LinqToSql, because it is not as smart as I supposed. Here is a code that confused me a little. from customer in db.Customers join customerGallery in db.CustomerGalleries on customer.ID equals customerGallery.CustomerID join profile in db.CustomerProfiles on customer.ID equals profile.CustomerID where (customerGallery.AlbumId != profile.CompanyHistoryAlbum) The context is that customer [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Flinqtosql-and-comparisons-with-null.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Flinqtosql-and-comparisons-with-null.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently, I have been very surprised by LinqToSql, because it is not as smart as I supposed. Here is a code that confused me a little.</p>
<pre>from customer in db.Customers
    join customerGallery in db.CustomerGalleries
        on customer.ID equals customerGallery.CustomerID
    join profile in db.CustomerProfiles
        on customer.ID equals profile.CustomerID
where
    (customerGallery.AlbumId != profile.CompanyHistoryAlbum)</pre>
<p>The context is that customer can have many galleries depending on his profile, but he always have one default gallery. The query above retrieves a default customer gallery – the one not used in any profile.</p>
<p>The problem in this query is that it won’t work when in column CompanyHistoryAlbum is NULL. LinqToSQL translates “!=” comparison to SQL as simple “&lt;&gt;”, so when NULL is compared to customerGallery.AlbumId UNKNOWN is returned and condition is not met.</p>
<p>More on that you can read <a href="http://msdn.microsoft.com/en-us/library/bb399342.aspx">here</a> (“Null semantics” section) and <a href="http://msdn.microsoft.com/en-us/library/ms191270%28SQL.90%29.aspx">here</a> (“Comparing Null Values” section). As a solution I added null check as if it was in SQL:</p>
<pre>from customer in db.Customers
    join customerGallery in db.CustomerGalleries
        on customer.ID equals customerGallery.CustomerID
    join profile in db.CustomerProfiles
        on customer.ID equals profile.CustomerID
where
    ((profile.CompanyHistoryAlbum == null) ||
    (customerGallery.AlbumId != profile.CompanyHistoryAlbum))</pre>
<p>I also <a href="http://www.brentlamborn.com/post/LINQ-to-SQL-Null-check-in-Where-Clause.aspx">found</a> that for comparisons with variables, e.g.:</p>
<pre>from customer in db.Customers
where
    (customer.Address == address)</pre>
<p>the best is to use object.Equals – LinqToSql will generate then appropriate NULL checks:</p>
<pre>from customer in db.Customers
where
    object.Equals(customer.Address, address)</pre>
<p>Hope it helps!</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html">http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/top-13-mysql-best-practices.html' rel='bookmark' title='Permanent Link: Top 13 MySQL best practices'>Top 13 MySQL best practices</a></li>
<li><a href='http://www.pgs-soft.com/new-features-in-nunit-2-5-part-2-testing-exceptions.html' rel='bookmark' title='Permanent Link: New features in NUnit 2.5. Part 2 &#8211; testing exceptions'>New features in NUnit 2.5. Part 2 &#8211; testing exceptions</a></li>
<li><a href='http://www.pgs-soft.com/hosting-asp-net-application-on-a-shared-server.html' rel='bookmark' title='Permanent Link: Hosting ASP.Net application on a shared server'>Hosting ASP.Net application on a shared server</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/linqtosql-and-comparisons-with-null.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException</title>
		<link>http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html</link>
		<comments>http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html#comments</comments>
		<pubDate>Fri, 05 Feb 2010 09:00:13 +0000</pubDate>
		<dc:creator>mstankala</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[ajax]]></category>
		<category><![CDATA[Ajax Control Toolkit]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[aspx]]></category>
		<category><![CDATA[AsyncPostBackTimeout]]></category>
		<category><![CDATA[PageRequestManagerTimeoutException]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=3079</guid>
		<description><![CDATA[How to avoid &#8220;PageRequestManagerTimeOutException&#8221; while using Ajax Control Toolkit? I was having a problem when developing an ASP.NET Web Application using Ajax Control Toolikit. On one of my Report pages, the constructed SQL query using LINQKit was pretty complex. It took a while for the SQL Server to return the results. The complexity depends on [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fajax-control-toolkit-pagerequestmanagertimeoutexception.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fajax-control-toolkit-pagerequestmanagertimeoutexception.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>How to avoid &#8220;PageRequestManagerTimeOutException&#8221; while using Ajax Control Toolkit?</strong></p>
<p>I was having a problem when developing an ASP.NET Web Application using <a href="http://www.codeplex.com/AjaxControlToolkit">Ajax Control Toolikit</a>.<br />
On one of my Report pages, the constructed SQL query using <a href="http://www.albahari.com/nutshell/linqkit.aspx">LINQKit</a> was pretty complex. It took a while for the SQL Server to return the results.<br />
The complexity depends on the amount of specified filter parameters by the user. There are also calculations and transformations performed on the SQL results, which of course affect the request execution time.<br />
This caused, that sometimes on my report page, when sending the Ajax request, the users browser noted a JavaScript error, instead of displaying the report.</p>
<p>First thought was to increase the Ajax PostBack Timeout. I can be set in the code behind &#8211; by default it&#8217;s set to 90 seconds:<br />
&#8230;<br />
<code style="font-family: courier">ScriptManager.AsyncPostBackTimeout = 120; <code style="color: green">//in seconds</code></code><br />
&#8230;<br />
But what if there are more users requesting a report at the same time? At least I need to inform them, why they didn&#8217;t get what they were expecting.</p>
<p>There is a possibility in the Ajax Control Toolkit, to attach user JavaScript code when the request ends.<br />
So if I attach my code that displays an alert message and/or redirects to an error page, that would be great! I could better handle this timeout.</p>
<p>So in the Master Page, after the ScriptManager control, I&#8217;ve added new JavaScript code:</p>
<p><a href="http://www.pgs-soft.com/wp-content/uploads/2010/02/PageRequestManagerTimeoutException3.jpg"><img src="http://www.pgs-soft.com/wp-content/uploads/2010/02/PageRequestManagerTimeoutException3.jpg" alt="Ajax Control Toolkit PageRequestManagerTimeoutException" width="525" class="aligncenter size-full wp-image-3097" /></a></p>
<p>Some explanation of this code sample:<br />
- get the current Script Manager instance<br />
- attach custom endRequest event function<br />
- check if the request ends with an error of the type:<br />
 &nbsp;&nbsp;<code style="font-family:courier">Sys.WebForms.PageRequestManagerTimeoutException</code><br />
- if the above^ condition is true, notice the Script Manager that this<br />
&nbsp;&nbsp;error was handled (prevent from JavaScript errors in users browser)<br />
- finally redirect to custom error page (display error message, send error<br />
&nbsp;&nbsp;emails, etc.)</p>
<p>Additionally the <code style="font-family:courier">reqManager._postBackSettings.panelID</code> provides me extra informs about the update panel that started the request, because there are more of them on one page.</p>
<p>So this &#8220;simple&#8221; JavaScript code performs a timeout error check for all Ajax request in my Web Application.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html">http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html' rel='bookmark' title='Permanent Link: Using jQuery to fit thumbnails'>Using jQuery to fit thumbnails</a></li>
<li><a href='http://www.pgs-soft.com/hosting-asp-net-application-on-a-shared-server.html' rel='bookmark' title='Permanent Link: Hosting ASP.Net application on a shared server'>Hosting ASP.Net application on a shared server</a></li>
<li><a href='http://www.pgs-soft.com/introduction-to-xval.html' rel='bookmark' title='Permanent Link: Introduction to xVal'>Introduction to xVal</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>FireQuery &#8211; Firebug extension for jQuery development</title>
		<link>http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html</link>
		<comments>http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html#comments</comments>
		<pubDate>Wed, 27 Jan 2010 10:01:20 +0000</pubDate>
		<dc:creator>mstankala</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Firefox]]></category>
		<category><![CDATA[FireQuery]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[Outsourcing]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=2970</guid>
		<description><![CDATA[The most interesting feature of this add-on, is displaying extra jQuery attributes attached to an HTML element, using the jQuery.data() method. That means NOT standard HTML tag attributes like: CSS Class name, Size, etc. Due to the JQuery API &#8220;the jQuery.data() method allows us to attach data of any type to DOM elements in a [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Ffirequery-firebug-extension-for-jquery-development.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Ffirequery-firebug-extension-for-jquery-development.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery2.jpg"><img class="size-large wp-image-2947" src="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery2-800x444.jpg" alt="FireQuery – Firebug extension for jQuery development" width="420" /></a></p>
<p>The most interesting feature of this add-on, is displaying extra jQuery attributes attached to an HTML element, using the jQuery.data() method. That means NOT standard HTML tag attributes like: CSS Class name, Size, etc.<br />
Due to the <a href="http://api.jquery.com/jQuery.data/">JQuery API</a> &#8220;the jQuery.data() method allows us to attach data of any type to DOM elements in a way that is safe from circular references and therefore from memory leaks&#8221;.<br />
Using this JQuery method is really easy:</p>
<pre>
&lt;script type="text/javascript"&gt;
   //Look into the Firebug HTML Tab
   //and watch the BODY Tag.
   //You should see the [Extradata] in there.
   $('body').data('Extradata', {
       Prop1: "Test1",
       Prop2: "Test2"
   });
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Other useful feature of this add-on is, the JQuery methods are on the top of the Firebug DOM window list, or at least in the Top 20 :).</p>
<p>Last but not least you can display FireQuery information about HTML tags in the Firebug console, using the console.log() command:</p>
<pre>...
&lt;script type="text/javascript"&gt;
   //This command will display in the Firebug console
   //extra jQuery attributes of the BODY tag.
   console.log($('body'));
&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;
</pre>
<p>Complete FireQuery test source code:<br />
<a href="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery_source.jpg"><img src="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery_source.jpg" alt="FireQuery test source code" width="420" class="size-full wp-image-2977" /></a></p>
<p>FireQuery additional information in Firebug:<br />
<a href="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery_Firebug1.jpg"><img src="http://www.pgs-soft.com/wp-content/uploads/2010/01/FireQuery_Firebug1.jpg" alt="FireQuery results in Firebug" width="420" class="size-full wp-image-2979" /></a></p>
<p>Without any doubts I can say, that this extra information may be sometimes helpful and can improve my work when developing websites using <a href="http://jquery.com/">JQuery JavaScript Library</a>, but you need to be careful! The author writes, that this extension may be insecure. Good solution is to have dedicated <a href="http://support.mozilla.com/en-US/kb/Profiles">Firefox profile</a> for development and use it only for safe sites.</p>
<p>This Firefox Add-on can be download from the <a href="http://firequery.binaryage.com/">Binaryage website</a>.<br />
Also a <a href="http://firequery.binaryage.com/test/index.html">FireQuery demo page</a> was provided for tests.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html">http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/jquery-1-4-released.html' rel='bookmark' title='Permanent Link: jQuery 1.4 Released!'>jQuery 1.4 Released!</a></li>
<li><a href='http://www.pgs-soft.com/new-firebug-1-5-released.html' rel='bookmark' title='Permanent Link: New Firebug 1.5 released'>New Firebug 1.5 released</a></li>
<li><a href='http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html' rel='bookmark' title='Permanent Link: Using jQuery to fit thumbnails'>Using jQuery to fit thumbnails</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>New Firebug 1.5 released</title>
		<link>http://www.pgs-soft.com/new-firebug-1-5-released.html</link>
		<comments>http://www.pgs-soft.com/new-firebug-1-5-released.html#comments</comments>
		<pubDate>Fri, 22 Jan 2010 10:55:07 +0000</pubDate>
		<dc:creator>mstankala</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[Firebug]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=2857</guid>
		<description><![CDATA[New Firebug 1.5 for Firefox was released. The most interesting new feature for me, is the &#8220;Breakpoints on DOM (HTML) Mutation Events&#8221;. It stops the javascript debugger, when a specified element(HTML tags, Javascript objects) or property get changed. It even stops and displays the line of javascript, which caused the change. This feature will relay [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fnew-firebug-1-5-released.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fnew-firebug-1-5-released.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p><a href="http://blog.getfirebug.com/2010/01/15/firebug-1-5-0/">New Firebug 1.5 for Firefox was released</a>.</p>
<p>The most interesting new feature for me, is the &#8220;Breakpoints on DOM (HTML) Mutation Events&#8221;.<br />
It stops the javascript debugger, when a specified element(HTML tags, Javascript objects) or property get changed.<br />
It even stops and displays the line of javascript, which caused the change. This feature will relay improve my work as a Web Developer.</p>
<p><a href="http://getfirebug.com/doc/breakpoints/demo.html">An official Firebug 1.5 demo</a> will introduce you to all new features.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/new-firebug-1-5-released.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/new-firebug-1-5-released.html">http://www.pgs-soft.com/new-firebug-1-5-released.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html' rel='bookmark' title='Permanent Link: FireQuery &#8211; Firebug extension for jQuery development'>FireQuery &#8211; Firebug extension for jQuery development</a></li>
<li><a href='http://www.pgs-soft.com/jquery-1-4-released.html' rel='bookmark' title='Permanent Link: jQuery 1.4 Released!'>jQuery 1.4 Released!</a></li>
<li><a href='http://www.pgs-soft.com/asp-mvc-2-preview.html' rel='bookmark' title='Permanent Link: ASP MVC 2 Preview'>ASP MVC 2 Preview</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/new-firebug-1-5-released.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using jQuery to fit thumbnails</title>
		<link>http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html</link>
		<comments>http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html#comments</comments>
		<pubDate>Thu, 14 Jan 2010 10:39:37 +0000</pubDate>
		<dc:creator>gwidziszowski</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[design]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=2689</guid>
		<description><![CDATA[The problem I&#8217;ve run onto a problem today: I had a bunch of thumbnail files that should be displayed in a gallery page in fixed-size boxes, but each image had different dimensions. It&#8217;s easy to fit images to a box using css and width/height properties &#8211; you can apply one of them (i.e. width), and [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fusing-jquery-to-fit-thumbnails.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fusing-jquery-to-fit-thumbnails.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<h3>The problem</h3>
<p>I&#8217;ve run onto a problem today: I had a bunch of thumbnail files that should be displayed in a gallery page in fixed-size boxes, but each image had different dimensions.</p>
<p>It&#8217;s easy to fit images to a box using css and width/height properties &#8211; you can apply one of them (i.e. width), and leave the other not set &#8211; the image will be resized and will keep it&#8217;s aspect ratio.</p>
<p>The problem arises, when you have to fit images to a box (say 160px x 200px), but images can have any possible size. You have to handle wide images (i.e. 250px x 100px) as well as narrow ones (100px x 250px).</p>
<h3>The solution</h3>
<p>There are several ways to deal with image sizing on web pages:</p>
<ul>
<li>using plain css  &#8211; but this is not a cross-browser solution</li>
<li>if the images are generated within your application &#8211; refactor the thumbnail generation procedure to output images that fit perfectly into the box</li>
<li>use client-side javascript</li>
</ul>
<p>When your application has to deal with already existing files, then you&#8217;re left only with the last solution.</p>
<h3>jQuery</h3>
<p>Javascript image manipulation is tricky when you have to deal with dimensions, events and still keep it working on all major browsers. That&#8217;s why I have choosen jQuery for that. The main reason is that jQuery separates you from the browser &#8211; you don&#8217;t have to waste time implementing bunch of &#8220;ifs&#8221; for each browser.</p>
<p>In my code the images are outputted using this part of HTML code:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;div</span> <span style="color: #000066;">style</span>=<span style="color: #ff0000;">&quot;overflow: hidden;width: 160px;height: 200px&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;a</span> <span style="color: #000066;">href</span>=<span style="color: #ff0000;">&quot;target_to_image_or_gallery&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;img</span> <span style="color: #000066;">class</span>=<span style="color: #ff0000;">&quot;imageFitBox&quot;</span> <span style="color: #000066;">src</span>=<span style="color: #ff0000;">&quot;some_thumbnail.jpg?rnd=5624562456&quot;</span> <span style="color: #000066;">alt</span>=<span style="color: #ff0000;">&quot;(Image is missing)&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/a<span style="color: #000000; font-weight: bold;">&gt;</span></span><span style="color: #000000; font-weight: bold;">&lt;/div<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>If you use ASP or PHP or any other server-side processed scripting language, you will probably use some controls to output the images, links etc. It doesn&#8217;t matter whether you put that part into table cells, floating divs or any other construct.</p>
<p>Important parts in the code above:</p>
<ul>
<li>the outer div element has fixed size</li>
</ul>
<ul>
<li>image&#8217;s class name is set to &#8220;imageFitBox&#8221;</li>
</ul>
<ul>
<li>image&#8217;s url is extended with a random number (can be also current date or anything simmilar) to prevent browser from image caching. This is required, because some of browsers when displaying a cached image do not set up the javascript width / height properties of a image.</li>
</ul>
<ul>
<li>code is a part of document&#8217;s DOM (it can&#8217;t be in a  detached node kept in javascript variable &#8211; it must be part of page)</li>
</ul>
<p>The jQuery part :</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">//attach to onload event - it's fired when entire page is loaded (icluding images)</span>
$<span style="color: #009900;">&#40;</span>window<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">load</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
 <span style="color: #006600; font-style: italic;">//iterate the images that have the imageFitBox class set up</span>
 $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'img.imageFitBox'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">each</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
 <span style="color: #009900;">&#123;</span>
  <span style="color: #006600; font-style: italic;">//check if image height exceeds the maximal height of box</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">200</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//if so - limit only the height to maximal height</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'200px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #006600; font-style: italic;">//IMPORTANT! after setting up the height, check the width</span>
  <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span> <span style="color: #CC0000;">160</span><span style="color: #009900;">&#41;</span>
  <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">//reset the height...</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'height'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">''</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #006600; font-style: italic;">//.. and apply width constraint</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'width'</span><span style="color: #339933;">,</span><span style="color: #3366CC;">'160px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #006600; font-style: italic;">// you can also set up the margins of image, to center it inside the box</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'margin-left'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">160</span><span style="color: #339933;">-</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">width</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'margin-top'</span><span style="color: #339933;">,</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> <span style="color: #CC0000;">200</span><span style="color: #339933;">-</span>$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">height</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">/</span><span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #3366CC;">'px'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p><em>Note: WordPress forces &amp;gt and &amp;lt in code blocks. Please replace it with &gt; and &lt; operators.</em></p>
<p>You can put the jQuery script any place you want &#8211; it can be in a separate javascript file or inisde the HTML page.<br />
To get jQuery and see how to use it visit <a href="http://jquery.com/">jQuery homepage</a>.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html#comments">Comments (1)</a> - originally posted here <a href="http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html">http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/firequery-firebug-extension-for-jquery-development.html' rel='bookmark' title='Permanent Link: FireQuery &#8211; Firebug extension for jQuery development'>FireQuery &#8211; Firebug extension for jQuery development</a></li>
<li><a href='http://www.pgs-soft.com/jquery-1-4-released.html' rel='bookmark' title='Permanent Link: jQuery 1.4 Released!'>jQuery 1.4 Released!</a></li>
<li><a href='http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html' rel='bookmark' title='Permanent Link: Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException'>Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/using-jquery-to-fit-thumbnails.html/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ASP.NET Site Performance Tips and Tricks</title>
		<link>http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html</link>
		<comments>http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html#comments</comments>
		<pubDate>Mon, 17 Aug 2009 13:42:41 +0000</pubDate>
		<dc:creator>Marcin Stawarz</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[asp]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=2607</guid>
		<description><![CDATA[Recently we had to deal with really big page produced as output from ASP.NET web site. While looking some solutions of possible improvements I&#8217;ve found very nice article. Author has gathered some very useful tips and links in one place. So in case you are interested in practical performence improvements of ASP.NET I recommend you [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fasp-net-site-performance-tips-and-tricks.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fasp-net-site-performance-tips-and-tricks.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Recently we had to deal with really big page produced as output from ASP.NET web site. While looking some solutions of possible improvements I&#8217;ve found very nice article. Author has gathered some very useful tips and links in one place. So in case you are interested in practical performence improvements of ASP.NET I recommend you to take a look at this post.</p>
<p><a href="http://www.codeproject.com/KB/aspnet/aspnetPerformance.aspx">http://www.codeproject.com/KB/aspnet/aspnetPerformance.aspx</a></p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html">http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/validatorcalloutextender-and-server-validation-in-asp-net.html' rel='bookmark' title='Permanent Link: ValidatorCalloutExtender and server validation in ASP.NET'>ValidatorCalloutExtender and server validation in ASP.NET</a></li>
<li><a href='http://www.pgs-soft.com/asp-net-session-mockup.html' rel='bookmark' title='Permanent Link: ASP.NET session mockup'>ASP.NET session mockup</a></li>
<li><a href='http://www.pgs-soft.com/visual-studio-2010-beta-2-and-ajax-library.html' rel='bookmark' title='Permanent Link: Visual Studio 2010 Beta 2 and Ajax Library'>Visual Studio 2010 Beta 2 and Ajax Library</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The type &#8216;x&#8217; exists in both &#8216;y1.dll&#8217; and &#8216;y2.dll&#8217;</title>
		<link>http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html</link>
		<comments>http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html#comments</comments>
		<pubDate>Fri, 24 Jul 2009 11:40:54 +0000</pubDate>
		<dc:creator>Waldemar Mękal</dc:creator>
				<category><![CDATA[Developers]]></category>
		<category><![CDATA[asp.net]]></category>
		<category><![CDATA[tips & tricks]]></category>

		<guid isPermaLink="false">http://www.pgs-soft.com/?p=2595</guid>
		<description><![CDATA[Today, I have opened a demo ASP.Net 2.o project in Visual Studio 2008. Everything was compiling just fine, but after running the project I saw the following message: Compiler Error Message: CS0433: The type &#8216;x&#8217; exists in both &#8216;c:\Users\myuser\AppData\Local\Temp\Temporary ASP.NET Files\root \336e1678\ef5434a2\assembly\dl3\ae492fce\7da7bd16_c706ca01\y.DLL&#8217; and &#8216;c:\Users\myuser\AppData\Local\Temp\Temporary ASP.NET Files\root \336e1678\ef5434a2\x.ascx.cs.cdcab7d2.qcmqdjk8.dll&#8217; The &#8216;x&#8217; was an user (&#8216;ascx&#8217;) control. After [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px; margin-top: 5px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.pgs-soft.com%2Fthe-type-x-exists-in-both-y1-dll-and-y2-dll.html"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.pgs-soft.com%2Fthe-type-x-exists-in-both-y1-dll-and-y2-dll.html&amp;source=pgssoftware&amp;style=normal&amp;service=bit.ly" height="61" width="50" /><br />
			</a>
		</div>
<p>Today, I have opened  a demo ASP.Net 2.o project in Visual Studio 2008. Everything was compiling just fine, but after running the project I saw the following message:</p>
<blockquote><p>Compiler Error Message: </strong>CS0433: The type &#8216;x&#8217; exists in both<br />
&#8216;c:\Users\myuser\AppData\Local\Temp\Temporary ASP.NET Files\root<br />
\336e1678\ef5434a2\assembly\dl3\ae492fce\7da7bd16_c706ca01\y.DLL&#8217;<br />
and &#8216;c:\Users\myuser\AppData\Local\Temp\Temporary ASP.NET Files\root<br />
\336e1678\ef5434a2\x.ascx.cs.cdcab7d2.qcmqdjk8.dll&#8217;</p></blockquote>
<p>The &#8216;x&#8217; was an user (&#8216;ascx&#8217;) control. After searching and trying many solutions I have found one matching. I had to replace &#8216;Src&#8217; page directive with &#8216;CodeBehind&#8217; in control markup.</p>
<pre><%-- old one --%>
<%@ Control Language="C#" AutoEventWireup="true"
    Src="x.ascx.cs" Inherits="x"%>

<%-- working one --%>
<%@ Control Language="C#" AutoEventWireup="true"
    CodeBehind="x.ascx.cs" Inherits="x"%></pre>
<p>Other solutions that might be helpful for you are here: <a title="http://forums.asp.net/t/980517.aspx" href="http://forums.asp.net/t/980517.aspx" target="_self">http://forums.asp.net/t/980517.aspx</a>.</p>
<p>Hope this will help.</p>
<hr /><small>Copyright &copy; 2004 - 2010 by <a href="http://www.pgs-soft.com">PGS Software</a>
<br/><br/>
<a href="http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html#comments">Comments (0)</a> - originally posted here <a href="http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html">http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html</a> </small>

<h2>Related posts</h2><ol><li><a href='http://www.pgs-soft.com/asp-net-site-performance-tips-and-tricks.html' rel='bookmark' title='Permanent Link: ASP.NET Site Performance Tips and Tricks'>ASP.NET Site Performance Tips and Tricks</a></li>
<li><a href='http://www.pgs-soft.com/ajax-control-toolkit-pagerequestmanagertimeoutexception.html' rel='bookmark' title='Permanent Link: Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException'>Ajax Control Toolkit &#8211; PageRequestManagerTimeOutException</a></li>
<li><a href='http://www.pgs-soft.com/oracle-database-gateway.html' rel='bookmark' title='Permanent Link: Oracle Database Gateway'>Oracle Database Gateway</a></li>
</ol>]]></content:encoded>
			<wfw:commentRss>http://www.pgs-soft.com/the-type-x-exists-in-both-y1-dll-and-y2-dll.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
