<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>LifeCycle Solutions, LLC - Weblog - ASP.NET</title>
    <link>http://blog.lifecycle-solutions.com/</link>
    <description>Technical Writing</description>
    <language>en-us</language>
    <copyright>LifeCycle Solutions, LLC</copyright>
    <lastBuildDate>Wed, 17 Oct 2007 19:06:09 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>info@lifecycle-solutions.com</managingEditor>
    <webMaster>info@lifecycle-solutions.com</webMaster>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=3b32e616-9485-41f9-8bea-e5f7e79ac6b5</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,3b32e616-9485-41f9-8bea-e5f7e79ac6b5.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,3b32e616-9485-41f9-8bea-e5f7e79ac6b5.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3b32e616-9485-41f9-8bea-e5f7e79ac6b5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
One technique we've started using is automating our apps' configuration using Pre-Build
Events and Build Configurations in Visual Studio.  It takes a little more work
to set up, but once you do, publishing test and production apps is much easier. 
It also helps the developer to think not just about a "<a href="http://www.codinghorror.com/blog/archives/000818.html">works
on my machine</a>" app, but an app that works on any number of scenarios.  Without
this approach, the developer still has to keep up with multiple config files, but
typically does so in their head. Scott Guthrie has a <a href="http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx">great
post showing how all this is done</a>.  However, a few tips will help you
fine tune your automation, so that development is even more painless:
</p>
        <ul>
          <li>
Decide the different scenarios your app will run in.  In our case there are typically
3: 
<ul><li>
Local - App is being developed and running on the developers' PC 
</li><li>
Staging - App is being tested in a copy of the production environment 
</li><li>
Production - App is "live".</li></ul></li>
          <li>
Create a folder named Configuration. 
</li>
          <li>
Create a .config file for each scenario above. 
<ul><li><em>Name the .config file scenario.web.config or scenario.app.config (ie local.web.config). 
Using this approach over Scott's means you still get intellisense in the .config files!</em></li><li>
If you have an existing .config file, just copy it to the Configuration folder and
rename it as above.  Remember that after this is set up, the "real" .config
file will be overwritten.  If you put blank .config files in Configuration, you'll
loose the "real" configuration file.</li></ul></li>
          <li>
Create Build Configurations in Configuration Manager for each scenario above.  
<ul><li>
In each configuration, add the following Pre-Build event 
</li><li><font size="2"><p>
IF EXIST "$(ProjectDir)Configuration\$(ConfigurationName).web.config" xcopy "$(ProjectDir)Configuration\$(ConfigurationName).web.config"
"$(ProjectDir)\web.config" /Y /R
</p></font></li><li><font size="2"><p></p></font><em>This script accomodates the naming schema above, and works with source
control by overwritting the read-only .config file. Note if your project is a windows
forms, console, or class library app, change "web.config" to "app.config"</em></li></ul></li>
        </ul>
        <p>
And that's it - before each build, the appropriate config file will be copied
over and used.  Note that you'll never want to change the .config file in your
project's root, as it will be overwritten.  Instead, whenever you need to change
configuration, decide how the change will affect each scenario, and change each .config
in your Configuration folder.
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=3b32e616-9485-41f9-8bea-e5f7e79ac6b5" />
      </body>
      <title>Automate Your Configuration</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,3b32e616-9485-41f9-8bea-e5f7e79ac6b5.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2007/10/17/AutomateYourConfiguration.aspx</link>
      <pubDate>Wed, 17 Oct 2007 19:06:09 GMT</pubDate>
      <description>&lt;p&gt;
One technique we've started using is automating our apps' configuration using Pre-Build
Events and Build Configurations in Visual Studio.&amp;nbsp; It takes a little more work
to set up, but once you do, publishing test and production apps is much easier.&amp;nbsp;
It also helps the developer to think not just about a "&lt;a href="http://www.codinghorror.com/blog/archives/000818.html"&gt;works
on my machine&lt;/a&gt;" app, but an app that&amp;nbsp;works on any number of scenarios.&amp;nbsp;&amp;nbsp;Without
this approach, the developer still has to keep up with multiple config files, but
typically does so in&amp;nbsp;their head.&amp;nbsp;Scott Guthrie has a &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/09/21/tip-trick-automating-dev-qa-staging-and-production-web-config-settings-with-vs-2005.aspx"&gt;great
post showing how all&amp;nbsp;this is done&lt;/a&gt;.&amp;nbsp; However, a few tips will help you
fine tune your automation, so that development is even more painless:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Decide the different scenarios your app will run in.&amp;nbsp; In our case there are typically
3: 
&lt;ul&gt;
&lt;li&gt;
Local - App is being developed and running on the developers' PC 
&lt;li&gt;
Staging - App is being tested in a copy of the production environment 
&lt;li&gt;
Production - App is "live".&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Create a folder named Configuration. 
&lt;li&gt;
Create a .config file for each scenario above. 
&lt;ul&gt;
&lt;li&gt;
&lt;em&gt;Name the .config file scenario.web.config or scenario.app.config (ie local.web.config).&amp;nbsp;
Using this approach over Scott's means you still get intellisense in the .config files!&lt;/em&gt; 
&lt;li&gt;
If you have an existing .config file, just copy it to the Configuration folder and
rename it as above.&amp;nbsp; Remember that&amp;nbsp;after this is set up, the "real" .config
file will be overwritten.&amp;nbsp; If you put blank .config files in Configuration, you'll
loose the "real" configuration file.&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;
Create Build Configurations in Configuration Manager&amp;nbsp;for each scenario above.&amp;nbsp; 
&lt;ul&gt;
&lt;li&gt;
In each configuration, add the following Pre-Build event 
&lt;li&gt;
&lt;font size=2&gt; 
&lt;p&gt;
IF EXIST "$(ProjectDir)Configuration\$(ConfigurationName).web.config" xcopy "$(ProjectDir)Configuration\$(ConfigurationName).web.config"
"$(ProjectDir)\web.config" /Y /R
&lt;/p&gt;
&lt;/font&gt; 
&lt;li&gt;
&lt;font size=2&gt; 
&lt;p&gt;
&lt;/font&gt;&lt;em&gt;This script accomodates the naming schema above, and works with source
control by overwritting the read-only .config file. Note if your project is a windows
forms, console, or class library app, change "web.config" to "app.config"&lt;/em&gt;&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
And that's it - before each&amp;nbsp;build, the appropriate config file will be copied
over and used.&amp;nbsp; Note that you'll never want to change the .config file in your
project's root, as it will be overwritten.&amp;nbsp; Instead, whenever you need to change
configuration, decide how the change will affect each scenario, and change each .config
in your Configuration folder.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=3b32e616-9485-41f9-8bea-e5f7e79ac6b5" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,3b32e616-9485-41f9-8bea-e5f7e79ac6b5.aspx</comments>
      <category>ASP.NET</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=1361aace-70fe-4499-a78e-b9d2b67eb582</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,1361aace-70fe-4499-a78e-b9d2b67eb582.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,1361aace-70fe-4499-a78e-b9d2b67eb582.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1361aace-70fe-4499-a78e-b9d2b67eb582</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In the slides from <a href="http://weblogs.asp.net/scottgu/archive/2007/03/30/slides-from-my-asp-net-connections-talks-wpf-e-linq-and-asp-net-tips-tricks.aspx">Scott
Guthrie's 'ASP.NET Tips and Tricks' TechEd Presentation</a>, I ran across this gem. 
You can turn off debugging server-wide by adding the following to &lt;system.web&gt;
section in the server's machine.config file (typically located in C:\windows\Microsoft.NET\Framework\v&lt;version&gt;\Config):<br /><br />
       &lt;deployment retail="true"/&gt;
</p>
        <p>
This is a great backup in case developers forget to turn it off in the application
using &lt;compilation debug="false"/&gt;.  Scott also mentions a few of the negative
results of forgetting this little setting:
</p>
        <ul>
          <li>
Slower performance due to debug code</li>
          <li>
App uses much more memory</li>
          <li>
Client-side scripts are not cached</li>
        </ul>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=1361aace-70fe-4499-a78e-b9d2b67eb582" />
      </body>
      <title>How To: Disable deployment debug=true for entire server</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,1361aace-70fe-4499-a78e-b9d2b67eb582.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2007/04/02/HowToDisableDeploymentDebugtrueForEntireServer.aspx</link>
      <pubDate>Mon, 02 Apr 2007 14:09:25 GMT</pubDate>
      <description>&lt;p&gt;
In the slides from &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/03/30/slides-from-my-asp-net-connections-talks-wpf-e-linq-and-asp-net-tips-tricks.aspx"&gt;Scott
Guthrie's 'ASP.NET Tips and Tricks' TechEd Presentation&lt;/a&gt;, I ran across this gem.&amp;nbsp;
You can turn off debugging server-wide by adding the following to &amp;lt;system.web&amp;gt;
section in the server's machine.config file (typically located in C:\windows\Microsoft.NET\Framework\v&amp;lt;version&amp;gt;\Config):&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;deployment retail="true"/&amp;gt;
&lt;/p&gt;
&lt;p&gt;
This is a&amp;nbsp;great backup in case developers forget to turn it off in the application
using &amp;lt;compilation debug="false"/&amp;gt;.&amp;nbsp; Scott also mentions a few of the negative
results of forgetting this little setting:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Slower performance due to debug code&lt;/li&gt;
&lt;li&gt;
App uses much more memory&lt;/li&gt;
&lt;li&gt;
Client-side scripts are not cached&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=1361aace-70fe-4499-a78e-b9d2b67eb582" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,1361aace-70fe-4499-a78e-b9d2b67eb582.aspx</comments>
      <category>ASP.NET</category>
      <category>Patterns and Practices</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=5589150e-e518-45ff-a0a3-b74e8ddba757</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,5589150e-e518-45ff-a0a3-b74e8ddba757.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,5589150e-e518-45ff-a0a3-b74e8ddba757.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5589150e-e518-45ff-a0a3-b74e8ddba757</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <img style="FLOAT: right; MARGIN: 1em" src="http://blog.lifecycle-solutions.com/content/binary/ReflectorScreenshot.png" border="0" />
        <p>
One of the most useful tools for .NET development is <a href="http://www.aisto.com/roeder/dotnet/">Lutz
Roeder's .NET Reflector</a>, now in version 5.  It uses reflection to peek inside
.NET assemblies and disassembles the IL back into C# or VB code for those times that
you need an in-depth look into <em>any</em> .NET library.  Ever wonder what
the code for System.String looked like? This release adds some really nice
features:
</p>
        <ul>
          <li>
Formatted code comments- doubles as a documentation browser for XML code-commented
members 
</li>
          <li>
'Expand members' in disassembler lets you see code for an entire class at once-
previously you had to look at each method separately. 
</li>
          <li>
New analyzer features shows where classes are instantiated and exposed. 
</li>
          <li>
Search Google or MSDN for a member</li>
        </ul>
        <p>
In addition to helping you debug code, this is also a great learning tool.  What
better way to understand framework development than to peek inside The Framework itself?
</p>
        <p>
 
</p>
        <p>
 
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=5589150e-e518-45ff-a0a3-b74e8ddba757" />
      </body>
      <title>Essential Tool: Lutz Roeder's .NET Reflector v5</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,5589150e-e518-45ff-a0a3-b74e8ddba757.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2007/02/20/EssentialToolLutzRoedersNETReflectorV5.aspx</link>
      <pubDate>Tue, 20 Feb 2007 14:49:16 GMT</pubDate>
      <description>&lt;img style="FLOAT: right; MARGIN: 1em" src="http://blog.lifecycle-solutions.com/content/binary/ReflectorScreenshot.png" border=0&gt; 
&lt;p&gt;
One of the most useful tools for .NET development is&amp;nbsp;&lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;Lutz
Roeder's .NET Reflector&lt;/a&gt;, now in version 5.&amp;nbsp; It uses reflection to peek inside
.NET assemblies and disassembles the IL back into C# or VB code for those times that
you need an in-depth look into &lt;em&gt;any&lt;/em&gt;&amp;nbsp;.NET library.&amp;nbsp; Ever wonder&amp;nbsp;what
the code for System.String looked like?&amp;nbsp;This&amp;nbsp;release adds some really&amp;nbsp;nice
features:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
Formatted code comments- doubles as a documentation browser for XML code-commented
members 
&lt;li&gt;
'Expand members' in disassembler lets you see code for&amp;nbsp;an entire class at once-
previously you had to look at each method separately. 
&lt;li&gt;
New analyzer features shows where classes are instantiated and exposed. 
&lt;li&gt;
Search Google or MSDN for a member&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
In addition to helping you debug code, this is also a great learning tool.&amp;nbsp; What
better way to understand framework development than to peek inside The Framework itself?
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=5589150e-e518-45ff-a0a3-b74e8ddba757" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,5589150e-e518-45ff-a0a3-b74e8ddba757.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>Documentation</category>
      <category>Patterns and Practices</category>
      <category>Training</category>
      <category>Visual Studio</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=e0abb29b-997d-4b06-be56-7af26676d63d</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,e0abb29b-997d-4b06-be56-7af26676d63d.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,e0abb29b-997d-4b06-be56-7af26676d63d.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e0abb29b-997d-4b06-be56-7af26676d63d</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Ever wondered what a secure ASP.NET 2.0 application should look like?  The <a href="http://blogs.msdn.com/jmeier/archive/2006/07/20/672959.aspx">ASP.NET
Internet Security Reference Implementation</a> rolls all of the <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/SecurityGuidanceIndex.asp">Patterns
and Practices Security Guidance</a> into real-world sample application, complete with
full documentation about all of the security features, why and how they were
implemented, and the drawbacks to doing so.
</p>
        <p>
If you are doing ASP.NET 1.1 or 2.0 web design, you should download this, read through
it, and check out the code.  While the code is 2.0, all of the security concepts-
and some of the solutions- map to 1.1 apps as well.
</p>
        <p>
One note: it installs into C:\Program Files\Microsoft\Internet Security Reference
Implementation by default.  It took me forever to find it!
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=e0abb29b-997d-4b06-be56-7af26676d63d" />
      </body>
      <title>ASP.NET 2.0 Internet Security Reference Implementation</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,e0abb29b-997d-4b06-be56-7af26676d63d.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/23/ASPNET20InternetSecurityReferenceImplementation.aspx</link>
      <pubDate>Wed, 23 Aug 2006 21:51:30 GMT</pubDate>
      <description>&lt;p&gt;
Ever wondered what a secure ASP.NET 2.0 application should look like?&amp;nbsp; The &lt;a href="http://blogs.msdn.com/jmeier/archive/2006/07/20/672959.aspx"&gt;ASP.NET
Internet Security Reference Implementation&lt;/a&gt; rolls all of the &lt;a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/SecurityGuidanceIndex.asp"&gt;Patterns
and Practices Security Guidance&lt;/a&gt; into real-world sample application, complete with
full documentation about all of the security features, why and how&amp;nbsp;they were
implemented, and the drawbacks to doing so.
&lt;/p&gt;
&lt;p&gt;
If you are doing ASP.NET 1.1 or 2.0 web design, you should download this, read through
it, and check out the code.&amp;nbsp; While the code is 2.0, all of the security concepts-
and some of the solutions-&amp;nbsp;map to 1.1 apps as well.
&lt;/p&gt;
&lt;p&gt;
One note: it installs into C:\Program Files\Microsoft\Internet Security Reference
Implementation by default.&amp;nbsp; It took me forever to find it!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=e0abb29b-997d-4b06-be56-7af26676d63d" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,e0abb29b-997d-4b06-be56-7af26676d63d.aspx</comments>
      <category>ASP.NET</category>
      <category>Documentation</category>
      <category>Patterns and Practices</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=ab8af175-056b-478a-bbb9-0ece3ac5c5e1</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,ab8af175-056b-478a-bbb9-0ece3ac5c5e1.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,ab8af175-056b-478a-bbb9-0ece3ac5c5e1.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ab8af175-056b-478a-bbb9-0ece3ac5c5e1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I recently data bound to a DateTime property in ASP.NET 2.0, and couldn't figure out
why the formatting wasn't working properly.  I set the DataFormatString property
to {0:d}, which should change the column to short date format.  But it wasn't
formatting at all.  After a little digging, I found that it was because HtmlEncode
wasn't set to false.  Setting HtmlEncode="false" on the column fixed the
problem.  
</p>
        <p>
Seems a bit odd at first, but the purpose of HtmlEncode is to prevent cross-site-script
attacks.  Here's what's happening:
</p>
        <ul>
          <li>
The property's value is retrieved. 
</li>
          <li>
ASP.NET converts the value to a string and formats it to remove any HTML. 
For example a '&lt;' gets changed to '&amp;lt;'.  So, if someone were to somehow
add the value &lt;script&gt;doSomethingTricksy()&lt;/script&gt; to your database,
it wouldn't get run here... 
</li>
          <li>
ASP.NET applies the DataFormatString, but by now the date is already a string.  
</li>
          <li>
Formatting the <em>string</em> "1/1/2005 12:00:00 PM" doesn't do anything.</li>
        </ul>
        <p>
Since we know the type is a date, and it would be difficult to insert HTML into
the date, then it's pretty safe to turn off this feature for this column.  Microsoft
has a little note on this issue <a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx">here</a>.
</p>
        <p>
I say pretty safe, because it's actually still possible that script or other HTML
could be inserted into this column.  A <a href="http://www.hanselman.com/blog/EnablingEvilOverridingSystemDateTimesDefaultToString.aspx">recent
post by Scott Hanselman</a> may give you a clue.  Suppose you let users define
their own DateTime formatting preferences, and did something <em>really</em> evil,
like this:
</p>
        <blockquote>
          <p>
customCulture.DateTimeFormat.ShortDatePattern = Request("format").ToString()<br />
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture<br />
System.Threading.Thread.CurrentThread.CurrentUICulture = customCulture
</p>
        </blockquote>
        <p>
And then suppose some crafty hacker sent a link to  yourpage.aspx?format=&lt;script&gt;doSomethingTricksy()&lt;/script&gt;MM/dd/yyyy. 
Any time you databound to a DateTime, if HtmlEncode was false, then the script would
be run! Once somebody gets that far, they can do <a href="http://en.wikipedia.org/wiki/Cross_site_scripting">any
number of bad things</a>.
</p>
        <p>
Granted, it's a pretty low threat, but it's worth knowing about.
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=ab8af175-056b-478a-bbb9-0ece3ac5c5e1" />
      </body>
      <title>Gets Me Every Time</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,ab8af175-056b-478a-bbb9-0ece3ac5c5e1.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/17/GetsMeEveryTime.aspx</link>
      <pubDate>Thu, 17 Aug 2006 21:07:29 GMT</pubDate>
      <description>&lt;p&gt;
I recently data bound to a DateTime property in ASP.NET 2.0, and couldn't figure out
why the formatting wasn't working properly.&amp;nbsp; I set the DataFormatString property
to {0:d}, which should change the column to short date format.&amp;nbsp; But it wasn't
formatting at all.&amp;nbsp; After a little digging, I found that it was because HtmlEncode
wasn't set to false.&amp;nbsp; Setting HtmlEncode="false" on the column&amp;nbsp;fixed the
problem.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Seems a bit odd at first,&amp;nbsp;but the purpose of HtmlEncode is to prevent cross-site-script
attacks.&amp;nbsp; Here's what's happening:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
The property's value is retrieved. 
&lt;li&gt;
ASP.NET converts the value to a&amp;nbsp;string and formats it to remove any HTML.&amp;nbsp;
For example a '&amp;lt;' gets changed to '&amp;amp;lt;'.&amp;nbsp; So, if someone were to somehow
add the value &amp;lt;script&amp;gt;doSomethingTricksy()&amp;lt;/script&amp;gt; to your database,
it wouldn't get run here... 
&lt;li&gt;
ASP.NET applies the DataFormatString, but by now the date is already a string.&amp;nbsp; 
&lt;li&gt;
Formatting the &lt;em&gt;string&lt;/em&gt; "1/1/2005 12:00:00 PM" doesn't do anything.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Since we know the type is a date, and it would be difficult&amp;nbsp;to insert HTML into
the date, then it's pretty safe to turn off this feature for this column.&amp;nbsp; Microsoft
has a little note on this issue &lt;a href="http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.boundfield.dataformatstring.aspx"&gt;here&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
I say pretty safe, because it's actually still possible that script or other HTML
could be inserted into this column.&amp;nbsp; A &lt;a href="http://www.hanselman.com/blog/EnablingEvilOverridingSystemDateTimesDefaultToString.aspx"&gt;recent
post by Scott Hanselman&lt;/a&gt; may give you a clue.&amp;nbsp; Suppose you let users define
their own DateTime formatting preferences, and did something &lt;em&gt;really&lt;/em&gt;&amp;nbsp;evil,
like this:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
customCulture.DateTimeFormat.ShortDatePattern =&amp;nbsp;Request("format").ToString()&lt;br&gt;
System.Threading.Thread.CurrentThread.CurrentCulture = customCulture&lt;br&gt;
System.Threading.Thread.CurrentThread.CurrentUICulture = customCulture
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
And then suppose some crafty hacker sent a link to&amp;nbsp; yourpage.aspx?format=&amp;lt;script&amp;gt;doSomethingTricksy()&amp;lt;/script&amp;gt;MM/dd/yyyy.&amp;nbsp;
Any time you databound to a DateTime, if HtmlEncode was false, then the script would
be run! Once somebody gets that far, they can do &lt;a href="http://en.wikipedia.org/wiki/Cross_site_scripting"&gt;any
number of bad things&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
Granted, it's a pretty low&amp;nbsp;threat,&amp;nbsp;but it's worth knowing about.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=ab8af175-056b-478a-bbb9-0ece3ac5c5e1" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,ab8af175-056b-478a-bbb9-0ece3ac5c5e1.aspx</comments>
      <category>ASP.NET</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=2e7db478-d205-415b-9afb-c912224cef15</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,2e7db478-d205-415b-9afb-c912224cef15.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,2e7db478-d205-415b-9afb-c912224cef15.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=2e7db478-d205-415b-9afb-c912224cef15</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">The Portable Network Graphics (PNG) format
is a great image format.  It's file sizes are typically much smaller than GIF
or JPG, and it supports alpha transparency.  So, you can have a transparent background
on your image, and it will look correct on any page.  With GIF or JPG, a designer
would need to carefully adjust the image background to match the page background. 
The only problem with PNG, is that IE doesn't support it natively!  Instead of
rendering the transparent areas correctly, they are displayed as opaque grey areas.  
Fortunately, IE 7 supposedly fixes that, and there are workarounds for IE 5.5 and
6.  Bob Osola has a <a href="http://homepage.ntlworld.com/bobosola/">nice explanation
and a javascript fix</a>.<br /><br />
Suppose we wanted to package this solution in a way that makes it easy for ASP.NET
developers to use, or we have custom controls that will rely on this fix.  Currently,
they would have to keep up with the client script, and reference it from each page
in each application they wrote.  Using Web Resources and Client Script Management
in ASP.NET 2.0, we can greatly simplify reuse of this script.<br /><br /><b>Solution Overview</b><br />
The fix itself is a little javascript that must be run on every page that requires
PNG support.  It works by looping through all the elements on a page and, if
it's an &lt;img&gt; element with a .png image, applying the CSS filter to fix PNG
in IE.  We've modified it slightly to do the same for &lt;input type="image"&gt;
elements, such as those rendered by the DataGridView's command button columns. 
As is, the developer must add the script to their application, and add this line to
the &lt;head&gt; element of each page that needs PNG transparency:<br /><br />
&lt;!--[if lt IE 7]&gt;<br />
&lt;script defer type="text/javascript" src="pngfix.js"&gt;&lt;/script&gt;<br />
&lt;![endif]--&gt;<br /><br />
But, we want the solution to be easy for developers to use.  From the application
developer's perspective, we want the expirience to be: 
<br /><ul><li>
Add a reference to MyCompany.Web.dll</li><li>
Add the line MyCompany.Web.UI.ClientScriptManager.EnablePNGSupport(...) to a control,
page, or master page's OnLoad event.</li></ul><b>Setting it up</b><br />
This tells us that we'll need a MyCompany.Web Class Library Project, and a class called
'ClientScriptManager'.  So in VS05, create a project named MyCompany.Web. 
For various reasons, it's also a good idea to set the default namespace to empty here. 
This will let you set the namespace inside your class, and will make using Web Resources
easier.  To do this:<br /><ul><li>
Rt Click the project</li><li>
Choose Properties</li><li>
Choose the Application Tab</li><li>
Empty the 'Default Namespace' field.</li></ul><b>Embedding Resources</b><br />
Next, create a folder named Resources, and add the <a href="http://blog.lifecycle-solutions.com/content/binary/pngfix.js">pngfix.js</a> file
to it.  To use this javascript file from web applications, it needs to be embedded
in the assembly and marked as a web resource.  Follow these steps to do this:<br /><ul><li>
Right click the script file and choose 'Properties'</li><li>
Set Build Action to 'Embedded Resource'.</li><li>
Go to the Solution Explorer and click 'Show All Files'</li><li>
Expand the 'My Project' item</li><li>
Open AssemblyInfo.vb</li><li>
Add this line to the bottom: &lt;Assembly: WebResource("pngfix.js", "text/javascript")&gt;</li><li>
Note: If you didn't set the default namespace to empty as above, you'll need to include
it here  (ie: "MyCompany.Web.pngfix.js")<br /></li></ul>
To recap, this just told the compiler to take the pngfix.js file and stuff it into
the .dll when it's compiled, and mark it as usable by web applications.  This
fix also requires a blank image file to work correctly.  Do the same as above
for the file <a href="http://blog.lifecycle-solutions.com/content/binary/blank.gif">blank.gif.</a><br /><br /><b>Getting Resources at the Client</b><br />
The last step is to create a method that will allow developers to easily use this
javascript.  This method needs to add a script to the page to set the path to
blank.gif, and a script to run the fix in pngfix.js.  But remember that file
has been embedded in a dll, so that our developers don't have to keep up with it.
This is where Web Resources come in.  To get the content that was embedded into
the dll, ASP.NET 2.0 gives us a method named GetWebResourceUrl(...).  When called,
this method returns a URL to a special path that looks something like this:<br /><br />
/WebResource.axd?d=rN9s8cQhdsLqV...<br /><br />
This location actually maps to an HttpHandler built in to ASP.NET 2.0, which will
do the work of pulling the embedded resource out of our assembly, and returning it
to the client.  So, to get the embedded resource- be it a script, image, or any
other file, all we need to do is browse to the url provided by GetWebResourceUrl. 
But, your developers shouldn't have to worry about all that.<br /><br />
The code below creates a class with a shared method for registering the two scripts
needed for this fix to work.  It first checks to see if the browser is IE 5.5
or 6.  Next, it checks to be sure the script isn't already registered, since
adding it twice would cause errors. Finally, it registers the scripts.<br /><br /><!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs24 \cf2 Imports\cf0  System.Web.UI.WebControls\par ??\cf2 Imports\cf0  System.Web.UI\par ??\cf2 Imports\cf0  System.Web\par ??\par ??\par ??\cf2 Namespace\cf0  CAP.Web.UI\par ??    \cf11 ''' \cf15 &lt;summary&gt;\par ??\cf0     \cf11 ''' Class for managing client side scripts frequently used by Civil Air Patrol web applications.\par ??\cf0     \cf11 ''' \cf15 &lt;/summary&gt;\par ??\cf0     \cf11 ''' \cf15 &lt;remarks&gt;&lt;/remarks&gt;\par ??\cf0     \cf2 Public\cf0  \cf2 Class\cf0  ClientScriptManager\par ??\par ??        \cf11 ''' \cf15 &lt;summary&gt;\par ??\cf0         \cf11 ''' Adds client script to add PNG transparency support to Internet Explorer 6.0 and lower browsers, \par ??\cf0         \cf11 ''' if it has not already been added by a previous call to this method.\par ??\cf0         \cf11 ''' \cf15 &lt;/summary&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;param name="page"&gt;\cf11 The page.\cf15 &lt;/param&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;remarks&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;para&gt;\cf11 IE 6 and lower do not properly display PNGs with transparent backgrounds.\par ??\cf0         \cf11 ''' This method puts a javascript include tag in the page's &amp;lt;head&amp;gt; declaration\par ??\cf0         \cf11 ''' if the browser is IE 6 or 5.5. This fix is based on the one \par ??\cf0         \cf11 ''' found here: http://homepage.ntlworld.com/bobosola\par ??\cf0         \cf11 ''' \cf15 &lt;/para&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;para&gt;\par ??\cf0         \cf11 ''' Typically this would be done using Page.ClientScript, however that method does\par ??\cf0         \cf11 ''' not support the 'defer' attribute, which is required in this case.\par ??\cf0         \cf11 ''' \cf15 &lt;/para&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;para&gt;\par ??\cf0         \cf11 ''' To use, add the following to your Page or MasterPage:\par ??\cf0         \cf11 ''' \cf15 &lt;code&gt;\cf11         \par ??\cf0         \cf11 '''   Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init\par ??\cf0         \cf11 '''     CAP.Web.UI.ClientScriptManager.AddPNGSupport(Me.Page)\par ??\cf0         \cf11 '''   End Sub\par ??\cf0         \cf11 ''' \cf15 &lt;/code&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;/para&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;/remarks&gt;\par ??\cf0         \cf2 Public\cf0  \cf2 Shared\cf0  \cf2 Sub\cf0  EnsurePNGSupport(\cf2 ByVal\cf0  page \cf2 As\cf0  System.Web.UI.Page)\par ??            \cf2 If\cf0  HttpContext.Current.Request.Browser.Browser = \cf13 "IE"\cf0  \cf2 Then\par ??\cf0                 \cf2 Dim\cf0  Version \cf2 As\cf0  \cf2 Double\cf0  = \cf2 CDbl\cf0 (HttpContext.Current.Request.Browser.Version)\par ??                \cf2 If\cf0  Version &lt; 7.0 \cf2 And\cf0  Version &gt; 5.5 \cf2 Then\par ??\cf0                     \cf2 Dim\cf0  pageHeader \cf2 As\cf0  System.Web.UI.HtmlControls.HtmlHead = page.Header\par ??\par ??                    \cf2 If\cf0  \cf2 Not\cf0  pageHeader.Page.ClientScript.IsClientScriptBlockRegistered(\cf13 "SetBlankImageUrl"\cf0 ) \cf2 Then\par ??\cf0                         \cf2 Dim\cf0  blankImageScript \cf2 As\cf0  \cf2 String\cf0  = \cf2 String\cf0 .Format(\cf13 "&lt;script type=""text/javascript""&gt;var blankImageUrl = '\{0\}'&lt;/script&gt;"\cf0 , pageHeader.Page.ClientScript.GetWebResourceUrl(\cf2 GetType\cf0 (CAP.Web.UI.ClientScriptManager), \cf13 "blank.gif"\cf0 ))\par ??                        pageHeader.Page.ClientScript.RegisterClientScriptBlock(pageHeader.Page.GetType(), \cf13 "SetBlankImageUrl"\cf0 , blankImageScript)\par ??                    \cf2 End\cf0  \cf2 If\par ??\par ??\cf0                     \cf2 If\cf0  \cf2 Not\cf0  ContainsControlWithId(pageHeader.Controls, \cf13 "pngFixBlock"\cf0 ) \cf2 Then\par ??\cf0                         \cf2 Dim\cf0  scriptBlock \cf2 As\cf0  \cf2 New\cf0  LiteralControl(\cf2 String\cf0 .Format(\cf13 "&lt;script defer type=""text/javascript"" src=""\{0\}""&gt;&lt;/script&gt;"\cf0 , pageHeader.Page.ClientScript.GetWebResourceUrl(\cf2 GetType\cf0 (CAP.Web.UI.ClientScriptManager), \cf13 "pngfix.js"\cf0 )))\par ??                        scriptBlock.ID = \cf13 "pngFixBlock"\par ??\par ??\cf0                         pageHeader.Controls.Add(scriptBlock)\par ??                    \cf2 End\cf0  \cf2 If\par ??\par ??\cf0                 \cf2 End\cf0  \cf2 If\par ??\cf0             \cf2 End\cf0  \cf2 If\par ??\cf0         \cf2 End\cf0  \cf2 Sub\par ??\par ??\cf0         \cf11 ''' \cf15 &lt;summary&gt;\par ??\cf0         \cf11 ''' Gets a value indicating whether a control with the given id already exists in a collection.\par ??\cf0         \cf11 ''' \cf15 &lt;/summary&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;param name="controls"&gt;&lt;/param&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;param name="id"&gt;&lt;/param&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;returns&gt;&lt;/returns&gt;\par ??\cf0         \cf11 ''' \cf15 &lt;remarks&gt;&lt;/remarks&gt;\par ??\cf0         \cf2 Private\cf0  \cf2 Shared\cf0  \cf2 Function\cf0  ContainsControlWithId(\cf2 ByVal\cf0  controls \cf2 As\cf0  ControlCollection, \cf2 ByVal\cf0  id \cf2 As\cf0  \cf2 String\cf0 ) \cf2 As\cf0  \cf2 Boolean\par ??\cf0             \cf2 For\cf0  \cf2 Each\cf0  control \cf2 As\cf0  Control \cf2 In\cf0  controls\par ??                \cf2 If\cf0  control.ID = id \cf2 Then\cf0  \cf2 Return\cf0  \cf2 True\par ??\cf0             \cf2 Next\par ??\cf0             \cf2 Return\cf0  \cf2 False\par ??\cf0         \cf2 End\cf0  \cf2 Function\par ??\cf0     \cf2 End\cf0  \cf2 Class\par ??End\cf0  \cf2 Namespace\par ??}
--><div style="background: white none repeat scroll 0% 50%; width: 450px; font-family: Consolas; font-size: 12pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><p style="margin: 0px;"><span style="color: blue;">Imports</span> System.Web.UI.WebControls
</p><p style="margin: 0px;"><span style="color: blue;">Imports</span> System.Web.UI
</p><p style="margin: 0px;"><span style="color: blue;">Imports</span> System.Web
</p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
 
</p><p style="margin: 0px;"><span style="color: blue;">Namespace</span> MyCompany.Web.UI
</p><p style="margin: 0px;">
    <span style="color: green;">''' </span><span style="color: gray;">&lt;summary&gt;</span></p><p style="margin: 0px;">
    <span style="color: green;">''' Class for managing client side
scripts frequently used by MyCompany web applications.</span></p><p style="margin: 0px;">
    <span style="color: green;">''' </span><span style="color: gray;">&lt;/summary&gt;</span></p><p style="margin: 0px;">
    <span style="color: green;">''' </span><span style="color: gray;">&lt;remarks&gt;&lt;/remarks&gt;</span></p><p style="margin: 0px;">
    <span style="color: blue;">Public</span><span style="color: blue;">Class</span> ClientScriptManager
</p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;summary&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' Adds client
script to add PNG transparency support to Internet Explorer 6.0 and lower browsers, </span></p><p style="margin: 0px;">
        <span style="color: green;">''' if it has not
already been added by a previous call to this method.</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/summary&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;param
name="page"&gt;</span><span style="color: green;">The page.</span><span style="color: gray;">&lt;/param&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;remarks&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;para&gt;</span><span style="color: green;">IE
6 and lower do not properly display PNGs with transparent backgrounds.</span></p><p style="margin: 0px;">
        <span style="color: green;">''' This method
puts a javascript include tag in the page's &amp;lt;head&amp;gt; declaration</span></p><p style="margin: 0px;">
        <span style="color: green;">''' if the browser
is IE 6 or 5.5. This fix is based on the one </span></p><p style="margin: 0px;">
        <span style="color: green;">''' found here:
http://homepage.ntlworld.com/bobosola</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/para&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;para&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' Typically this
would be done using Page.ClientScript, however that method does</span></p><p style="margin: 0px;">
        <span style="color: green;">''' not support
the 'defer' attribute, which is required in this case.</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/para&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;para&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' To use, add
the following to your Page or MasterPage:</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;code&gt;</span><span style="color: green;">   
    </span></p><p style="margin: 0px;">
        <span style="color: green;">'''  
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Init</span></p><p style="margin: 0px;">
        <span style="color: green;">'''    </span>MyCompany<span style="color: green;">.Web.UI.ClientScriptManager.AddPNGSupport(Me.Page)</span></p><p style="margin: 0px;">
        <span style="color: green;">'''  
End Sub</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/code&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/para&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/remarks&gt;</span></p><p style="margin: 0px;">
        <span style="color: blue;">Public</span><span style="color: blue;">Shared</span><span style="color: blue;">Sub</span> EnsurePNGSupport(<span style="color: blue;">ByVal</span> page <span style="color: blue;">As</span> System.Web.UI.Page)
</p><p style="margin: 0px;">
            <span style="color: blue;">If</span> HttpContext.Current.Request.Browser.Browser
= <span style="color: maroon;">"IE"</span><span style="color: blue;">Then</span></p><p style="margin: 0px;">
                <span style="color: blue;">Dim</span> Version <span style="color: blue;">As</span><span style="color: blue;">Double</span> = <span style="color: blue;">CDbl</span>(HttpContext.Current.Request.Browser.Version)
</p><p style="margin: 0px;">
                <span style="color: blue;">If</span> Version
&lt; 7.0 <span style="color: blue;">And</span> Version &gt; 5.5 <span style="color: blue;">Then</span></p><p style="margin: 0px;">
                    <span style="color: blue;">Dim</span> pageHeader <span style="color: blue;">As</span> System.Web.UI.HtmlControls.HtmlHead
= page.Header
</p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
                    <span style="color: blue;">If</span><span style="color: blue;">Not</span> pageHeader.Page.ClientScript.IsClientScriptBlockRegistered( <span style="color: maroon;">"SetBlankImageUrl"</span>) <span style="color: blue;">Then</span></p><p style="margin: 0px;">
                   
    <span style="color: blue;">Dim</span> blankImageScript <span style="color: blue;">As</span><span style="color: blue;">String</span> = <span style="color: blue;">String</span>.Format(<span style="color: maroon;">"&lt;script
type=""text/javascript""&gt;var blankImageUrl = '{0}'&lt;/script&gt;"</span>, pageHeader.Page.ClientScript.GetWebResourceUrl(<span style="color: blue;"> GetType</span>(MyCompany.Web.UI.ClientScriptManager), <span style="color: maroon;">"blank.gif"</span>))
</p><p style="margin: 0px;">
                   
    pageHeader.Page.ClientScript.RegisterClientScriptBlock( pageHeader.Page.GetType(), <span style="color: maroon;">"SetBlankImageUrl"</span>,
blankImageScript)
</p><p style="margin: 0px;">
                    <span style="color: blue;">End</span><span style="color: blue;">If</span></p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
                    <span style="color: blue;">If</span><span style="color: blue;">Not</span> ContainsControlWithId(pageHeader.Controls, <span style="color: maroon;">"pngFixBlock"</span>) <span style="color: blue;">Then</span></p><p style="margin: 0px;">
                   
    <span style="color: blue;">Dim</span> scriptBlock <span style="color: blue;">As</span><span style="color: blue;">New</span> LiteralControl(<span style="color: blue;">String</span>.Format(<span style="color: maroon;">"&lt;script
defer type=""text/javascript"" src=""{0}""&gt;&lt;/script&gt;"</span>, pageHeader.Page.ClientScript.GetWebResourceUrl(<span style="color: blue;"> GetType</span>(MyCompany.Web.UI.ClientScriptManager), <span style="color: maroon;">"pngfix.js"</span>)))
</p><p style="margin: 0px;">
                   
    scriptBlock.ID = <span style="color: maroon;">"pngFixBlock"</span></p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
                   
    pageHeader.Controls.Add(scriptBlock)
</p><p style="margin: 0px;">
                    <span style="color: blue;">End</span><span style="color: blue;">If</span></p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
                <span style="color: blue;">End</span><span style="color: blue;">If</span></p><p style="margin: 0px;">
            <span style="color: blue;">End</span><span style="color: blue;">If</span></p><p style="margin: 0px;">
        <span style="color: blue;">End</span><span style="color: blue;">Sub</span></p><p style="margin: 0px;">
 
</p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;summary&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' Gets a value
indicating whether a control with the given id already exists in a collection.</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;/summary&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;param
name="controls"&gt;&lt;/param&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;param
name="id"&gt;&lt;/param&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;returns&gt;&lt;/returns&gt;</span></p><p style="margin: 0px;">
        <span style="color: green;">''' </span><span style="color: gray;">&lt;remarks&gt;&lt;/remarks&gt;</span></p><p style="margin: 0px;">
        <span style="color: blue;">Private</span><span style="color: blue;">Shared</span><span style="color: blue;">Function</span> ContainsControlWithId(<span style="color: blue;">ByVal</span> controls <span style="color: blue;">As</span> ControlCollection, <span style="color: blue;">ByVal</span> id <span style="color: blue;">As</span><span style="color: blue;">String</span>) <span style="color: blue;">As</span><span style="color: blue;">Boolean</span></p><p style="margin: 0px;">
            <span style="color: blue;">For</span><span style="color: blue;">Each</span> control <span style="color: blue;">As</span> Control <span style="color: blue;">In</span> controls
</p><p style="margin: 0px;">
                <span style="color: blue;">If</span> control.ID
= id <span style="color: blue;">Then</span><span style="color: blue;">Return</span><span style="color: blue;">True</span></p><p style="margin: 0px;">
            <span style="color: blue;">Next</span></p><p style="margin: 0px;">
            <span style="color: blue;">Return</span><span style="color: blue;">False</span></p><p style="margin: 0px;">
        <span style="color: blue;">End</span><span style="color: blue;">Function</span></p><p style="margin: 0px;">
    <span style="color: blue;">End</span><span style="color: blue;">Class</span></p><p style="margin: 0px;"><span style="color: blue;">End</span><span style="color: blue;">Namespace</span></p></div><br />
Copy the above, and put in a class called 'ClientScriptManager.vb.'<br /><br /><b>Using the Fix</b><br />
Build, and if everything worked correctly, your developers can reference the assembly
from their projects, and fix PNG transparency with a single line of code in their
page's OnLoad event:<br /><br />
MyCompany.Web.UI.ClientScriptManager.EnsurePNGSupport(Me)<br /><br />
An even better option would be to put this in a master page OnLoad event:<br /><br />
MyCompany.Web.UI.ClientScriptManager.EnsurePNGSupport(Me.Page)<br /><br />
Finally, it's worth noting that this would also work for custom controls.  You
can use the same technique to embed a png to be used by, say, the ImageUrl property
of your control.   The only gotcha is that the script looks for the .png
extension to determine if it needs to fix an element, but the URL returned by GetWebResourceUrl
doesn't end in '.png'.  To fix this, simply add the extension to the query string:<br /><br /><!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs24  \cf2 If\cf0  \cf2 Not\cf0  \cf2 String\cf0 .IsNullOrEmpty(\cf2 Me\cf0 .ImageUrl) \cf2 Then\par ??\cf0                 printLink.ImageUrl = ImageUrl\par ??            \cf2 ElseIf\cf0  \cf2 Me\cf0 .DesignMode \cf2 Then\par ??\cf0                 printLink.ImageUrl = \cf2 Me\cf0 .Page.ClientScript.GetWebResourceUrl(\cf2 Me\cf0 .GetType(), \cf13 "printer48.png"\cf0 )\par ??            \cf2 Else\par ??\cf0                 printLink.ImageUrl = \cf2 Me\cf0 .Page.ClientScript.GetWebResourceUrl(\cf2 Me\cf0 .GetType(), \cf13 "printer48.png"\cf0 ) + \cf13 "&amp;.png"\par ??\cf0             \cf2 End\cf0  \cf2 If}
--><div style="background: white none repeat scroll 0% 50%; width: 450px; font-family: Consolas; font-size: 12pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"><p style="margin: 0px;"><span style="color: blue;">If</span><span style="color: blue;">Not</span><span style="color: blue;">String</span>.IsNullOrEmpty(<span style="color: blue;">Me</span>.ImageUrl) <span style="color: blue;">Then</span></p><p style="margin: 0px;">
   printLink.ImageUrl = ImageUrl<br /><span style="color: blue;">ElseIf</span><span style="color: blue;">Me</span>.DesignMode <span style="color: blue;">Then</span></p><p style="margin: 0px;">
   printLink.ImageUrl = <span style="color: blue;">Me</span>.Page.ClientScript.GetWebResourceUrl(<span style="color: blue;">Me</span>.GetType(), <span style="color: maroon;">"printer48.png"</span>)
</p><p style="margin: 0px;"><span style="color: blue;">Else</span></p><p style="margin: 0px;">
   printLink.ImageUrl = <span style="color: blue;">Me</span>.Page.ClientScript.GetWebResourceUrl(<span style="color: blue;">Me</span>.GetType(), <span style="color: maroon;">"printer48.png"</span>)
+ <span style="color: maroon;">"&amp;.png"</span></p><p style="margin: 0px;"><span style="color: blue;">End</span><span style="color: blue;">If</span></p></div><p></p>
Files for this post:<br /><a href="http://blog.lifecycle-solutions.com/content/binary/pngfix.js">pngfix.js (2.19
KB)</a><br /><a href="http://blog.lifecycle-solutions.com/content/binary/blank.gif">blank.gif (.04
KB)</a><br /><br /><br /><img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=2e7db478-d205-415b-9afb-c912224cef15" /></body>
      <title>How To: Use Web Resources to Fix PNG Transparency in IE</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,2e7db478-d205-415b-9afb-c912224cef15.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/15/HowToUseWebResourcesToFixPNGTransparencyInIE.aspx</link>
      <pubDate>Tue, 15 Aug 2006 22:21:00 GMT</pubDate>
      <description>The Portable Network Graphics (PNG) format is a great image format.&amp;nbsp; It's file sizes are typically much smaller than GIF or JPG, and it supports alpha transparency.&amp;nbsp; So, you can have a transparent background on your image, and it will look correct on any page.&amp;nbsp; With GIF or JPG, a designer would need to carefully adjust the image background to match the page background.&amp;nbsp; The only problem with PNG, is that IE doesn't support it natively!&amp;nbsp; Instead of rendering the transparent areas correctly, they are displayed as opaque grey areas.&amp;nbsp;&amp;nbsp; Fortunately, IE 7 supposedly fixes that, and there are workarounds for IE 5.5 and 6.&amp;nbsp; Bob Osola has a &lt;a href="http://homepage.ntlworld.com/bobosola/"&gt;nice
explanation and a javascript fix&lt;/a&gt;.&lt;br&gt;
&lt;br&gt;
Suppose we wanted to package this solution in a way that makes it easy for ASP.NET
developers to use, or we have custom controls that will rely on this fix.&amp;nbsp; Currently,
they would have to keep up with the client script, and reference it from each page
in each application they wrote.&amp;nbsp; Using Web Resources and Client Script Management
in ASP.NET 2.0, we can greatly simplify reuse of this script.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Solution Overview&lt;/b&gt;
&lt;br&gt;
The fix itself is a little javascript that must be run on every page that requires
PNG support.&amp;nbsp; It works by looping through all the elements on a page and, if
it's an &amp;lt;img&amp;gt; element with a .png image, applying the CSS filter to fix PNG
in IE.&amp;nbsp; We've modified it slightly to do the same for &amp;lt;input type="image"&amp;gt;
elements, such as those rendered by the DataGridView's command button columns.&amp;nbsp;
As is, the developer must add the script to their application, and add this line to
the &amp;lt;head&amp;gt; element of each page that needs PNG transparency:&lt;br&gt;
&lt;br&gt;
&amp;lt;!--[if lt IE 7]&amp;gt;&lt;br&gt;
&amp;lt;script defer type="text/javascript" src="pngfix.js"&amp;gt;&amp;lt;/script&amp;gt;&lt;br&gt;
&amp;lt;![endif]--&amp;gt;&lt;br&gt;
&lt;br&gt;
But, we want the solution to be easy for developers to use.&amp;nbsp; From the application
developer's perspective, we want the expirience to be: 
&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Add a reference to MyCompany.Web.dll&lt;/li&gt;
&lt;li&gt;
Add the line MyCompany.Web.UI.ClientScriptManager.EnablePNGSupport(...) to a control,
page, or master page's OnLoad event.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Setting it up&lt;/b&gt;
&lt;br&gt;
This tells us that we'll need a MyCompany.Web Class Library Project, and a class called
'ClientScriptManager'.&amp;nbsp; So in VS05, create a project named MyCompany.Web.&amp;nbsp;
For various reasons, it's also a good idea to set the default namespace to empty here.&amp;nbsp;
This will let you set the namespace inside your class, and will make using Web Resources
easier.&amp;nbsp; To do this:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Rt Click the project&lt;/li&gt;
&lt;li&gt;
Choose Properties&lt;/li&gt;
&lt;li&gt;
Choose the Application Tab&lt;/li&gt;
&lt;li&gt;
Empty the 'Default Namespace' field.&lt;/li&gt;
&lt;/ul&gt;
&lt;b&gt;Embedding Resources&lt;/b&gt;
&lt;br&gt;
Next, create a folder named Resources, and add the &lt;a href="http://blog.lifecycle-solutions.com/content/binary/pngfix.js"&gt;pngfix.js&lt;/a&gt; file
to it.&amp;nbsp; To use this javascript file from web applications, it needs to be embedded
in the assembly and marked as a web resource.&amp;nbsp; Follow these steps to do this:&lt;br&gt;
&lt;ul&gt;
&lt;li&gt;
Right click the script file and choose 'Properties'&lt;/li&gt;
&lt;li&gt;
Set Build Action to 'Embedded Resource'.&lt;/li&gt;
&lt;li&gt;
Go to the Solution Explorer and click 'Show All Files'&lt;/li&gt;
&lt;li&gt;
Expand the 'My Project' item&lt;/li&gt;
&lt;li&gt;
Open AssemblyInfo.vb&lt;/li&gt;
&lt;li&gt;
Add this line to the bottom: &amp;lt;Assembly: WebResource("pngfix.js", "text/javascript")&amp;gt;&lt;/li&gt;
&lt;li&gt;
Note: If you didn't set the default namespace to empty as above, you'll need to include
it here&amp;nbsp; (ie: "MyCompany.Web.pngfix.js")&lt;br&gt;
&lt;/li&gt;
&lt;/ul&gt;
To recap, this just told the compiler to take the pngfix.js file and stuff it into
the .dll when it's compiled, and mark it as usable by web applications.&amp;nbsp; This
fix also requires a blank image file to work correctly.&amp;nbsp; Do the same as above
for the file &lt;a href="http://blog.lifecycle-solutions.com/content/binary/blank.gif"&gt;blank.gif.&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Getting Resources at the Client&lt;/b&gt;
&lt;br&gt;
The last step is to create a method that will allow developers to easily use this
javascript.&amp;nbsp; This method needs to add a script to the page to set the path to
blank.gif, and a script to run the fix in pngfix.js.&amp;nbsp; But remember that file
has been embedded in a dll, so that our developers don't have to keep up with it.
This is where Web Resources come in.&amp;nbsp; To get the content that was embedded into
the dll, ASP.NET 2.0 gives us a method named GetWebResourceUrl(...).&amp;nbsp; When called,
this method returns a URL to a special path that looks something like this:&lt;br&gt;
&lt;br&gt;
/WebResource.axd?d=rN9s8cQhdsLqV...&lt;br&gt;
&lt;br&gt;
This location actually maps to an HttpHandler built in to ASP.NET 2.0, which will
do the work of pulling the embedded resource out of our assembly, and returning it
to the client.&amp;nbsp; So, to get the embedded resource- be it a script, image, or any
other file, all we need to do is browse to the url provided by GetWebResourceUrl.&amp;nbsp;
But, your developers shouldn't have to worry about all that.&lt;br&gt;
&lt;br&gt;
The code below creates a class with a shared method for registering the two scripts
needed for this fix to work.&amp;nbsp; It first checks to see if the browser is IE 5.5
or 6.&amp;nbsp; Next, it checks to be sure the script isn't already registered, since
adding it twice would cause errors. Finally, it registers the scripts.&lt;br&gt;
&lt;br&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs24 \cf2 Imports\cf0  System.Web.UI.WebControls\par ??\cf2 Imports\cf0  System.Web.UI\par ??\cf2 Imports\cf0  System.Web\par ??\par ??\par ??\cf2 Namespace\cf0  CAP.Web.UI\par ??    \cf11 ''' \cf15 &amp;lt;summary&amp;gt;\par ??\cf0     \cf11 ''' Class for managing client side scripts frequently used by Civil Air Patrol web applications.\par ??\cf0     \cf11 ''' \cf15 &amp;lt;/summary&amp;gt;\par ??\cf0     \cf11 ''' \cf15 &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;\par ??\cf0     \cf2 Public\cf0  \cf2 Class\cf0  ClientScriptManager\par ??\par ??        \cf11 ''' \cf15 &amp;lt;summary&amp;gt;\par ??\cf0         \cf11 ''' Adds client script to add PNG transparency support to Internet Explorer 6.0 and lower browsers, \par ??\cf0         \cf11 ''' if it has not already been added by a previous call to this method.\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;param name="page"&amp;gt;\cf11 The page.\cf15 &amp;lt;/param&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;remarks&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;para&amp;gt;\cf11 IE 6 and lower do not properly display PNGs with transparent backgrounds.\par ??\cf0         \cf11 ''' This method puts a javascript include tag in the page's &amp;amp;lt;head&amp;amp;gt; declaration\par ??\cf0         \cf11 ''' if the browser is IE 6 or 5.5. This fix is based on the one \par ??\cf0         \cf11 ''' found here: http://homepage.ntlworld.com/bobosola\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/para&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;para&amp;gt;\par ??\cf0         \cf11 ''' Typically this would be done using Page.ClientScript, however that method does\par ??\cf0         \cf11 ''' not support the 'defer' attribute, which is required in this case.\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/para&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;para&amp;gt;\par ??\cf0         \cf11 ''' To use, add the following to your Page or MasterPage:\par ??\cf0         \cf11 ''' \cf15 &amp;lt;code&amp;gt;\cf11         \par ??\cf0         \cf11 '''   Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init\par ??\cf0         \cf11 '''     CAP.Web.UI.ClientScriptManager.AddPNGSupport(Me.Page)\par ??\cf0         \cf11 '''   End Sub\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/code&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/para&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/remarks&amp;gt;\par ??\cf0         \cf2 Public\cf0  \cf2 Shared\cf0  \cf2 Sub\cf0  EnsurePNGSupport(\cf2 ByVal\cf0  page \cf2 As\cf0  System.Web.UI.Page)\par ??            \cf2 If\cf0  HttpContext.Current.Request.Browser.Browser = \cf13 "IE"\cf0  \cf2 Then\par ??\cf0                 \cf2 Dim\cf0  Version \cf2 As\cf0  \cf2 Double\cf0  = \cf2 CDbl\cf0 (HttpContext.Current.Request.Browser.Version)\par ??                \cf2 If\cf0  Version &amp;lt; 7.0 \cf2 And\cf0  Version &amp;gt; 5.5 \cf2 Then\par ??\cf0                     \cf2 Dim\cf0  pageHeader \cf2 As\cf0  System.Web.UI.HtmlControls.HtmlHead = page.Header\par ??\par ??                    \cf2 If\cf0  \cf2 Not\cf0  pageHeader.Page.ClientScript.IsClientScriptBlockRegistered(\cf13 "SetBlankImageUrl"\cf0 ) \cf2 Then\par ??\cf0                         \cf2 Dim\cf0  blankImageScript \cf2 As\cf0  \cf2 String\cf0  = \cf2 String\cf0 .Format(\cf13 "&amp;lt;script type=""text/javascript""&amp;gt;var blankImageUrl = '\{0\}'&amp;lt;/script&amp;gt;"\cf0 , pageHeader.Page.ClientScript.GetWebResourceUrl(\cf2 GetType\cf0 (CAP.Web.UI.ClientScriptManager), \cf13 "blank.gif"\cf0 ))\par ??                        pageHeader.Page.ClientScript.RegisterClientScriptBlock(pageHeader.Page.GetType(), \cf13 "SetBlankImageUrl"\cf0 , blankImageScript)\par ??                    \cf2 End\cf0  \cf2 If\par ??\par ??\cf0                     \cf2 If\cf0  \cf2 Not\cf0  ContainsControlWithId(pageHeader.Controls, \cf13 "pngFixBlock"\cf0 ) \cf2 Then\par ??\cf0                         \cf2 Dim\cf0  scriptBlock \cf2 As\cf0  \cf2 New\cf0  LiteralControl(\cf2 String\cf0 .Format(\cf13 "&amp;lt;script defer type=""text/javascript"" src=""\{0\}""&amp;gt;&amp;lt;/script&amp;gt;"\cf0 , pageHeader.Page.ClientScript.GetWebResourceUrl(\cf2 GetType\cf0 (CAP.Web.UI.ClientScriptManager), \cf13 "pngfix.js"\cf0 )))\par ??                        scriptBlock.ID = \cf13 "pngFixBlock"\par ??\par ??\cf0                         pageHeader.Controls.Add(scriptBlock)\par ??                    \cf2 End\cf0  \cf2 If\par ??\par ??\cf0                 \cf2 End\cf0  \cf2 If\par ??\cf0             \cf2 End\cf0  \cf2 If\par ??\cf0         \cf2 End\cf0  \cf2 Sub\par ??\par ??\cf0         \cf11 ''' \cf15 &amp;lt;summary&amp;gt;\par ??\cf0         \cf11 ''' Gets a value indicating whether a control with the given id already exists in a collection.\par ??\cf0         \cf11 ''' \cf15 &amp;lt;/summary&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;param name="controls"&amp;gt;&amp;lt;/param&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;param name="id"&amp;gt;&amp;lt;/param&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;\par ??\cf0         \cf11 ''' \cf15 &amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;\par ??\cf0         \cf2 Private\cf0  \cf2 Shared\cf0  \cf2 Function\cf0  ContainsControlWithId(\cf2 ByVal\cf0  controls \cf2 As\cf0  ControlCollection, \cf2 ByVal\cf0  id \cf2 As\cf0  \cf2 String\cf0 ) \cf2 As\cf0  \cf2 Boolean\par ??\cf0             \cf2 For\cf0  \cf2 Each\cf0  control \cf2 As\cf0  Control \cf2 In\cf0  controls\par ??                \cf2 If\cf0  control.ID = id \cf2 Then\cf0  \cf2 Return\cf0  \cf2 True\par ??\cf0             \cf2 Next\par ??\cf0             \cf2 Return\cf0  \cf2 False\par ??\cf0         \cf2 End\cf0  \cf2 Function\par ??\cf0     \cf2 End\cf0  \cf2 Class\par ??End\cf0  \cf2 Namespace\par ??}
--&gt;
&lt;div style="background: white none repeat scroll 0% 50%; width: 450px; font-family: Consolas; font-size: 12pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Web.UI.WebControls
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Web.UI
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;Imports&lt;/span&gt; System.Web
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;Namespace&lt;/span&gt; MyCompany.Web.UI
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' Class for managing client side
scripts frequently used by MyCompany web applications.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt; ClientScriptManager
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' Adds client
script to add PNG transparency support to Internet Explorer 6.0 and lower browsers, &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' if it has not
already been added by a previous call to this method.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;param
name="page"&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;The page.&lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;remarks&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;IE
6 and lower do not properly display PNGs with transparent backgrounds.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' This method
puts a javascript include tag in the page's &amp;amp;lt;head&amp;amp;gt; declaration&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' if the browser
is IE 6 or 5.5. This fix is based on the one &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' found here:
http://homepage.ntlworld.com/bobosola&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' Typically this
would be done using Page.ClientScript, however that method does&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' not support
the 'defer' attribute, which is required in this case.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;para&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' To use, add
the following to your Page or MasterPage:&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;code&amp;gt;&lt;/span&gt;&lt;span style="color: green;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;'''&amp;nbsp;&amp;nbsp;
Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.Init&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;'''&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;MyCompany&lt;span style="color: green;"&gt;.Web.UI.ClientScriptManager.AddPNGSupport(Me.Page)&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;'''&amp;nbsp;&amp;nbsp;
End Sub&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/code&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/para&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Public&lt;/span&gt; &lt;span style="color: blue;"&gt;Shared&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt; EnsurePNGSupport(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; page &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Web.UI.Page)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;If&lt;/span&gt; HttpContext.Current.Request.Browser.Browser
= &lt;span style="color: maroon;"&gt;"IE"&lt;/span&gt; &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; Version &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Double&lt;/span&gt; = &lt;span style="color: blue;"&gt;CDbl&lt;/span&gt;(HttpContext.Current.Request.Browser.Version)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;If&lt;/span&gt; Version
&amp;lt; 7.0 &lt;span style="color: blue;"&gt;And&lt;/span&gt; Version &amp;gt; 5.5 &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; pageHeader &lt;span style="color: blue;"&gt;As&lt;/span&gt; System.Web.UI.HtmlControls.HtmlHead
= page.Header
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;If&lt;/span&gt; &lt;span style="color: blue;"&gt;Not&lt;/span&gt; pageHeader.Page.ClientScript.IsClientScriptBlockRegistered( &lt;span style="color: maroon;"&gt;"SetBlankImageUrl"&lt;/span&gt;) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; blankImageScript &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt; = &lt;span style="color: blue;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: maroon;"&gt;"&amp;lt;script
type=""text/javascript""&amp;gt;var blankImageUrl = '{0}'&amp;lt;/script&amp;gt;"&lt;/span&gt;, pageHeader.Page.ClientScript.GetWebResourceUrl(&lt;span style="color: blue;"&gt; GetType&lt;/span&gt;(MyCompany.Web.UI.ClientScriptManager), &lt;span style="color: maroon;"&gt;"blank.gif"&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pageHeader.Page.ClientScript.RegisterClientScriptBlock( pageHeader.Page.GetType(), &lt;span style="color: maroon;"&gt;"SetBlankImageUrl"&lt;/span&gt;,
blankImageScript)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;If&lt;/span&gt; &lt;span style="color: blue;"&gt;Not&lt;/span&gt; ContainsControlWithId(pageHeader.Controls, &lt;span style="color: maroon;"&gt;"pngFixBlock"&lt;/span&gt;) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Dim&lt;/span&gt; scriptBlock &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;New&lt;/span&gt; LiteralControl(&lt;span style="color: blue;"&gt;String&lt;/span&gt;.Format(&lt;span style="color: maroon;"&gt;"&amp;lt;script
defer type=""text/javascript"" src=""{0}""&amp;gt;&amp;lt;/script&amp;gt;"&lt;/span&gt;, pageHeader.Page.ClientScript.GetWebResourceUrl(&lt;span style="color: blue;"&gt; GetType&lt;/span&gt;(MyCompany.Web.UI.ClientScriptManager), &lt;span style="color: maroon;"&gt;"pngfix.js"&lt;/span&gt;)))
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; scriptBlock.ID = &lt;span style="color: maroon;"&gt;"pngFixBlock"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; pageHeader.Controls.Add(scriptBlock)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Sub&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' Gets a value
indicating whether a control with the given id already exists in a collection.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;/summary&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;param
name="controls"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;param
name="id"&amp;gt;&amp;lt;/param&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;returns&amp;gt;&amp;lt;/returns&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: green;"&gt;''' &lt;/span&gt;&lt;span style="color: gray;"&gt;&amp;lt;remarks&amp;gt;&amp;lt;/remarks&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Private&lt;/span&gt; &lt;span style="color: blue;"&gt;Shared&lt;/span&gt; &lt;span style="color: blue;"&gt;Function&lt;/span&gt; ContainsControlWithId(&lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; controls &lt;span style="color: blue;"&gt;As&lt;/span&gt; ControlCollection, &lt;span style="color: blue;"&gt;ByVal&lt;/span&gt; id &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt;) &lt;span style="color: blue;"&gt;As&lt;/span&gt; &lt;span style="color: blue;"&gt;Boolean&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;For&lt;/span&gt; &lt;span style="color: blue;"&gt;Each&lt;/span&gt; control &lt;span style="color: blue;"&gt;As&lt;/span&gt; Control &lt;span style="color: blue;"&gt;In&lt;/span&gt; controls
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;If&lt;/span&gt; control.ID
= id &lt;span style="color: blue;"&gt;Then&lt;/span&gt; &lt;span style="color: blue;"&gt;Return&lt;/span&gt; &lt;span style="color: blue;"&gt;True&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Next&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;Return&lt;/span&gt; &lt;span style="color: blue;"&gt;False&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Function&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Class&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;Namespace&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;br&gt;
Copy the above, and put in a class called 'ClientScriptManager.vb.'&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Using the Fix&lt;/b&gt;
&lt;br&gt;
Build, and if everything worked correctly, your developers can reference the assembly
from their projects, and fix PNG transparency with a single line of code in their
page's OnLoad event:&lt;br&gt;
&lt;br&gt;
MyCompany.Web.UI.ClientScriptManager.EnsurePNGSupport(Me)&lt;br&gt;
&lt;br&gt;
An even better option would be to put this in a master page OnLoad event:&lt;br&gt;
&lt;br&gt;
MyCompany.Web.UI.ClientScriptManager.EnsurePNGSupport(Me.Page)&lt;br&gt;
&lt;br&gt;
Finally, it's worth noting that this would also work for custom controls.&amp;nbsp; You
can use the same technique to embed a png to be used by, say, the ImageUrl property
of your control.&amp;nbsp;&amp;nbsp; The only gotcha is that the script looks for the .png
extension to determine if it needs to fix an element, but the URL returned by GetWebResourceUrl
doesn't end in '.png'.&amp;nbsp; To fix this, simply add the extension to the query string:&lt;br&gt;
&lt;br&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof1252\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0??;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;??\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;??\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;??\red192\green192\blue192;}??\fs24  \cf2 If\cf0  \cf2 Not\cf0  \cf2 String\cf0 .IsNullOrEmpty(\cf2 Me\cf0 .ImageUrl) \cf2 Then\par ??\cf0                 printLink.ImageUrl = ImageUrl\par ??            \cf2 ElseIf\cf0  \cf2 Me\cf0 .DesignMode \cf2 Then\par ??\cf0                 printLink.ImageUrl = \cf2 Me\cf0 .Page.ClientScript.GetWebResourceUrl(\cf2 Me\cf0 .GetType(), \cf13 "printer48.png"\cf0 )\par ??            \cf2 Else\par ??\cf0                 printLink.ImageUrl = \cf2 Me\cf0 .Page.ClientScript.GetWebResourceUrl(\cf2 Me\cf0 .GetType(), \cf13 "printer48.png"\cf0 ) + \cf13 "&amp;amp;.png"\par ??\cf0             \cf2 End\cf0  \cf2 If}
--&gt;
&lt;div style="background: white none repeat scroll 0% 50%; width: 450px; font-family: Consolas; font-size: 12pt; color: black; -moz-background-clip: -moz-initial; -moz-background-origin: -moz-initial; -moz-background-inline-policy: -moz-initial;"&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;If&lt;/span&gt; &lt;span style="color: blue;"&gt;Not&lt;/span&gt; &lt;span style="color: blue;"&gt;String&lt;/span&gt;.IsNullOrEmpty(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.ImageUrl) &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp; printLink.ImageUrl = ImageUrl&lt;br&gt;
&lt;span style="color: blue;"&gt;ElseIf&lt;/span&gt; &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.DesignMode &lt;span style="color: blue;"&gt;Then&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp; printLink.ImageUrl = &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Page.ClientScript.GetWebResourceUrl(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.GetType(), &lt;span style="color: maroon;"&gt;"printer48.png"&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;Else&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&amp;nbsp;&amp;nbsp; printLink.ImageUrl = &lt;span style="color: blue;"&gt;Me&lt;/span&gt;.Page.ClientScript.GetWebResourceUrl(&lt;span style="color: blue;"&gt;Me&lt;/span&gt;.GetType(), &lt;span style="color: maroon;"&gt;"printer48.png"&lt;/span&gt;)
+ &lt;span style="color: maroon;"&gt;"&amp;amp;.png"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px;"&gt;
&lt;span style="color: blue;"&gt;End&lt;/span&gt; &lt;span style="color: blue;"&gt;If&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
Files for this post:&lt;br&gt;
&lt;a href="http://blog.lifecycle-solutions.com/content/binary/pngfix.js"&gt;pngfix.js (2.19
KB)&lt;/a&gt;
&lt;br&gt;
&lt;a href="http://blog.lifecycle-solutions.com/content/binary/blank.gif"&gt;blank.gif (.04
KB)&lt;/a&gt;
&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=2e7db478-d205-415b-9afb-c912224cef15" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,2e7db478-d205-415b-9afb-c912224cef15.aspx</comments>
      <category>ASP.NET</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=a548e632-2842-42d4-8a9d-c1a1016f72f7</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,a548e632-2842-42d4-8a9d-c1a1016f72f7.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,a548e632-2842-42d4-8a9d-c1a1016f72f7.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a548e632-2842-42d4-8a9d-c1a1016f72f7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Microsoft is cranking out ASP.NET 2.0 how-to
videos at a record pace.  Brian Goldfarb lists <a href="http://blogs.msdn.com/bgold/archive/2006/02/20/535869.aspx">several
new ones here</a>. Scott Guthrie lists them also, and includes a few <a href="http://weblogs.asp.net/scottgu/archive/2006/02/26/Great-ASP.NET-2.0-Tutorial-Videos-Online.aspx">others
here</a>, including one on Microsoft's AJAXy toolkit, Atlas.<br /><br /><p></p><img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=a548e632-2842-42d4-8a9d-c1a1016f72f7" /></body>
      <title>More How-to Videos</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,a548e632-2842-42d4-8a9d-c1a1016f72f7.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/06/MoreHowtoVideos.aspx</link>
      <pubDate>Sun, 06 Aug 2006 21:38:19 GMT</pubDate>
      <description>Microsoft is cranking out ASP.NET 2.0 how-to videos at a record pace.&amp;nbsp; Brian Goldfarb lists &lt;a href="http://blogs.msdn.com/bgold/archive/2006/02/20/535869.aspx"&gt;several
new ones here&lt;/a&gt;. Scott Guthrie lists them also, and includes a few &lt;a href="http://weblogs.asp.net/scottgu/archive/2006/02/26/Great-ASP.NET-2.0-Tutorial-Videos-Online.aspx"&gt;others
here&lt;/a&gt;, including one on Microsoft's AJAXy toolkit, Atlas.&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=a548e632-2842-42d4-8a9d-c1a1016f72f7" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,a548e632-2842-42d4-8a9d-c1a1016f72f7.aspx</comments>
      <category>ASP.NET</category>
      <category>Training</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=da436f18-65b5-42e5-a862-4c76614a474e</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,da436f18-65b5-42e5-a862-4c76614a474e.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,da436f18-65b5-42e5-a862-4c76614a474e.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=da436f18-65b5-42e5-a862-4c76614a474e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Online labs are Microsoft's newest way
to learn about developer tools and techniques.  These guided tutorials give you
a real, live virtual PC pre-installed with everything you need- Visual Studio 05,
.NET 2.0, etc.  Just sign up and use the web-based remote desktop client to connect. 
There's a list of <a href="http://www.wwwcoder.com/main/parentid/533/site/6349/68/default.aspx">good
.NET 2.0 Labs</a> over at WWWCoder.<p></p><img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=da436f18-65b5-42e5-a862-4c76614a474e" /></body>
      <title>Try .NET 2.0 and Visual Studio 2005 With Zero Installation Pain</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,da436f18-65b5-42e5-a862-4c76614a474e.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/04/TryNET20AndVisualStudio2005WithZeroInstallationPain.aspx</link>
      <pubDate>Fri, 04 Aug 2006 14:18:05 GMT</pubDate>
      <description>Online labs are Microsoft's newest way to learn about developer tools and techniques.&amp;nbsp; These guided tutorials give you a real, live virtual PC pre-installed with everything you need- Visual Studio 05, .NET 2.0, etc.&amp;nbsp; Just sign up and use the web-based remote desktop client to connect.&amp;nbsp; There's a list of &lt;a href="http://www.wwwcoder.com/main/parentid/533/site/6349/68/default.aspx"&gt;good
.NET 2.0 Labs&lt;/a&gt; over at WWWCoder.&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=da436f18-65b5-42e5-a862-4c76614a474e" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,da436f18-65b5-42e5-a862-4c76614a474e.aspx</comments>
      <category>ASP.NET</category>
      <category>Training</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=c0477617-7b69-42b8-be95-49be30d282d4</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,c0477617-7b69-42b8-be95-49be30d282d4.aspx</pingback:target>
      <dc:creator>Daniel Root</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,c0477617-7b69-42b8-be95-49be30d282d4.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c0477617-7b69-42b8-be95-49be30d282d4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">Here is a nice short <a href="http://learnvisualstudio.net/Videos/3512.zip">video
on setting up security for a folder in ASP.NET 2.0</a>.  This was possible in
1.1, but 2.0 makes it even easier- no code required to secure your site by roles!<br /><p></p><img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=c0477617-7b69-42b8-be95-49be30d282d4" /></body>
      <title>Video: Setting Authentication on Entire Folders in ASP.NET</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,c0477617-7b69-42b8-be95-49be30d282d4.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/08/03/VideoSettingAuthenticationOnEntireFoldersInASPNET.aspx</link>
      <pubDate>Thu, 03 Aug 2006 14:48:30 GMT</pubDate>
      <description>Here is a nice short &lt;a href="http://learnvisualstudio.net/Videos/3512.zip"&gt;video
on setting up security for a folder in ASP.NET 2.0&lt;/a&gt;.&amp;nbsp; This was possible in
1.1, but 2.0 makes it even easier- no code required to secure your site by roles!&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=c0477617-7b69-42b8-be95-49be30d282d4" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,c0477617-7b69-42b8-be95-49be30d282d4.aspx</comments>
      <category>ASP.NET</category>
      <category>Video</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=646f5b63-5445-43d4-9485-ba209ae546ca</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,646f5b63-5445-43d4-9485-ba209ae546ca.aspx</pingback:target>
      <dc:creator>Brian Parks</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,646f5b63-5445-43d4-9485-ba209ae546ca.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=646f5b63-5445-43d4-9485-ba209ae546ca</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The introduction of the DataSource model in .NET 2.0 has made it much easier to perform
data binding in ASP.NET.  In most cases, it's trivial to use the SqlDataSource
and ObjectDataSource for purposes of binding and updating the backing data store when
a single row is changed.  However, there's no out-of-the-box way to use a DataSet
itself as the backing data store and later persist its entire batch of data to the
database.  Consider a shopping cart scenario in which you are adding multiple
rows to a temporary data store...you don't necessarily want to go to the DB each time
a row is added; rather, you'd prefer to perform a batch update at the end of the process.<br /><br />
Andres Aguiar presents a good solution to the problem by creating a custom data source
for this purpose -- the <a href="http://weblogs.asp.net/aaguiar/articles/432695.aspx">DataSetDataSource</a>.
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=646f5b63-5445-43d4-9485-ba209ae546ca" />
      </body>
      <title>The DataSet DataSource</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,646f5b63-5445-43d4-9485-ba209ae546ca.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/07/25/TheDataSetDataSource.aspx</link>
      <pubDate>Tue, 25 Jul 2006 21:57:29 GMT</pubDate>
      <description>&lt;p&gt;
The introduction of the DataSource model in .NET 2.0 has made it much easier to perform
data binding in ASP.NET.&amp;nbsp; In most cases, it's trivial to use the SqlDataSource
and ObjectDataSource for purposes of binding and updating the backing data store when
a single row is changed.&amp;nbsp; However, there's no out-of-the-box way to use a DataSet
itself as the backing data store and later persist its entire batch of data to the
database.&amp;nbsp; Consider a shopping cart scenario in which you are adding multiple
rows to a temporary data store...you don't necessarily want to go to the DB each time
a row is added; rather, you'd prefer to perform a batch update at the end of the process.&lt;br&gt;
&lt;br&gt;
Andres Aguiar presents a good solution to the problem by creating a custom data source
for this purpose -- the &lt;a href="http://weblogs.asp.net/aaguiar/articles/432695.aspx"&gt;DataSetDataSource&lt;/a&gt;.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=646f5b63-5445-43d4-9485-ba209ae546ca" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,646f5b63-5445-43d4-9485-ba209ae546ca.aspx</comments>
      <category>ASP.NET</category>
    </item>
    <item>
      <trackback:ping>http://blog.lifecycle-solutions.com/Trackback.aspx?guid=256288af-b10a-43ce-a0a1-5fa4480e65b3</trackback:ping>
      <pingback:server>http://blog.lifecycle-solutions.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.lifecycle-solutions.com/PermaLink,guid,256288af-b10a-43ce-a0a1-5fa4480e65b3.aspx</pingback:target>
      <dc:creator>Brian Parks</dc:creator>
      <wfw:comment>http://blog.lifecycle-solutions.com/CommentView,guid,256288af-b10a-43ce-a0a1-5fa4480e65b3.aspx</wfw:comment>
      <wfw:commentRss>http://blog.lifecycle-solutions.com/SyndicationService.asmx/GetEntryCommentsRss?guid=256288af-b10a-43ce-a0a1-5fa4480e65b3</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There is an excellent collection of <a href="http://www.asp.net/learn/videos/default.aspx?tabid=63">tutorial
videos </a>on the Official ASP.NET 2.0 web site.  While they are probably most
beneficial for developers seeking to learn about the new features in 2.0, they should
also be useful for those moving to ASP.NET 2.0 from other environments, like traditional
ASP or PHP.
</p>
        <img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=256288af-b10a-43ce-a0a1-5fa4480e65b3" />
      </body>
      <title>ASP.NET 2.0 Tutorial Videos</title>
      <guid isPermaLink="false">http://blog.lifecycle-solutions.com/PermaLink,guid,256288af-b10a-43ce-a0a1-5fa4480e65b3.aspx</guid>
      <link>http://blog.lifecycle-solutions.com/2006/07/20/ASPNET20TutorialVideos.aspx</link>
      <pubDate>Thu, 20 Jul 2006 19:29:44 GMT</pubDate>
      <description>&lt;p&gt;
There is an excellent collection of &lt;a href="http://www.asp.net/learn/videos/default.aspx?tabid=63"&gt;tutorial
videos &lt;/a&gt;on the Official ASP.NET 2.0 web site.&amp;nbsp; While they are probably most
beneficial for developers seeking to learn about the new features in 2.0, they should
also be useful for those moving to ASP.NET 2.0 from other environments, like traditional
ASP or PHP.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.lifecycle-solutions.com/aggbug.ashx?id=256288af-b10a-43ce-a0a1-5fa4480e65b3" /&gt;</description>
      <comments>http://blog.lifecycle-solutions.com/CommentView,guid,256288af-b10a-43ce-a0a1-5fa4480e65b3.aspx</comments>
      <category>ASP.NET</category>
    </item>
  </channel>
</rss>