<?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>Dave Arlin - Bloggin'</title>
    <link>http://blog.davearlin.com/</link>
    <description>learn forever</description>
    <language>en-us</language>
    <copyright>Dave Arlin</copyright>
    <lastBuildDate>Thu, 02 Jun 2011 18:55:06 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.2.8279.16125</generator>
    <managingEditor>dave@davearlin.com</managingEditor>
    <webMaster>dave@davearlin.com</webMaster>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=3d508d1a-e14e-4665-8326-d5f7e61e7de8</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,3d508d1a-e14e-4665-8326-d5f7e61e7de8.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,3d508d1a-e14e-4665-8326-d5f7e61e7de8.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3d508d1a-e14e-4665-8326-d5f7e61e7de8</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This update was released primarily to address a bit of a performance problem when
recovering from a tombstone.  e.g. after a phone call, or turning back on your
phone after having your phone screen turn off<strong>.</strong> In v1.3 and below,
the application upon recovering from the tombstone would act as though it was a first
time load.  It would attempt to log into Harvest and pull down the 7 days worth
of time entries for the current week.   Those server calls could take awhile
on a slow connection and can be annoying when your phone screen just shut off on you
when you were thinking about what to put in for a specific task.
</p>
        <p>
          <strong>v1.4 Updates:</strong>
        </p>
        <p>
- Upon resurrecting from a tombstone,  the app will load back up much faster
without re-logging back into Harvest.  It will take you the daily view at your
most recent selected date.
</p>
        <p>
- Various UI fixes:
</p>
        <ul>
          <ul>
            <li>
              <div align="left">Project &amp; Task popup header was getting cut off
</div>
            </li>
            <li>
              <div align="left">Client &amp; Project names now wrap on Project &amp; Task popup.
</div>
            </li>
            <li>
              <div align="left">When starting a second timer, the UI was incorrectly still displaying
the first timer.  The first timer will now be removed.
</div>
            </li>
            <li>
              <div align="left">On the Daily screen, a client with a long enough name would get
cut off or overlap with the project name.  This is now fixed.
</div>
            </li>
          </ul>
        </ul>
        <p align="left">
View and download the latest update at: <a href="http://windowsphonegeek.com/AppHub/Application/af1b1607-386c-e011-81d2-78e7d1fa76f8">http://windowsphonegeek.com/AppHub/Application/af1b1607-386c-e011-81d2-78e7d1fa76f8</a></p>
        <p align="left">
Also as a reminder, this application is EXCLUSIVELY for Harvest time tracking customers.  
If you are not a customer, this app won’t do you much good <img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blog.davearlin.com/content/binary/Windows-Live-Writer/TimeTraxHarvest-v1.4-Released_C1C7/wlEmoticon-smile_2.png" /> 
You should check out Harvest at <a href="http://www.getharvest.com/">http://www.getharvest.com/</a></p>
        <img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=3d508d1a-e14e-4665-8326-d5f7e61e7de8" />
      </body>
      <title>TimeTrax–Harvest v1.4 Released</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,3d508d1a-e14e-4665-8326-d5f7e61e7de8.aspx</guid>
      <link>http://blog.davearlin.com/2011/06/02/TimeTraxHarvestV14Released.aspx</link>
      <pubDate>Thu, 02 Jun 2011 18:55:06 GMT</pubDate>
      <description>&lt;p&gt;
This update was released primarily to address a bit of a performance problem when
recovering from a tombstone.&amp;nbsp; e.g. after a phone call, or turning back on your
phone after having your phone screen turn off&lt;strong&gt;.&lt;/strong&gt; In v1.3 and below,
the application upon recovering from the tombstone would act as though it was a first
time load.&amp;nbsp; It would attempt to log into Harvest and pull down the 7 days worth
of time entries for the current week.&amp;nbsp;&amp;nbsp; Those server calls could take awhile
on a slow connection and can be annoying when your phone screen just shut off on you
when you were thinking about what to put in for a specific task.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;v1.4 Updates:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
- Upon resurrecting from a tombstone,&amp;nbsp; the app will load back up much faster
without re-logging back into Harvest.&amp;nbsp; It will take you the daily view at your
most recent selected date.
&lt;/p&gt;
&lt;p&gt;
- Various UI fixes:
&lt;/p&gt;
&lt;ul&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;div align="left"&gt;Project &amp;amp; Task popup header was getting cut off
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;Client &amp;amp; Project names now wrap on Project &amp;amp; Task popup.
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;When starting a second timer, the UI was incorrectly still displaying
the first timer.&amp;nbsp; The first timer will now be removed.
&lt;/div&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;div align="left"&gt;On the Daily screen, a client with a long enough name would get
cut off or overlap with the project name.&amp;nbsp; This is now fixed.
&lt;/div&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;/ul&gt;
&lt;p align="left"&gt;
View and download the latest update at: &lt;a href="http://windowsphonegeek.com/AppHub/Application/af1b1607-386c-e011-81d2-78e7d1fa76f8"&gt;http://windowsphonegeek.com/AppHub/Application/af1b1607-386c-e011-81d2-78e7d1fa76f8&lt;/a&gt;
&lt;/p&gt;
&lt;p align="left"&gt;
Also as a reminder, this application is EXCLUSIVELY for Harvest time tracking customers.&amp;nbsp;&amp;nbsp;
If you are not a customer, this app won’t do you much good &lt;img style="border-bottom-style: none; border-left-style: none; border-top-style: none; border-right-style: none" class="wlEmoticon wlEmoticon-smile" alt="Smile" src="http://blog.davearlin.com/content/binary/Windows-Live-Writer/TimeTraxHarvest-v1.4-Released_C1C7/wlEmoticon-smile_2.png"&gt;&amp;nbsp;
You should check out Harvest at &lt;a href="http://www.getharvest.com/"&gt;http://www.getharvest.com/&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=3d508d1a-e14e-4665-8326-d5f7e61e7de8" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,3d508d1a-e14e-4665-8326-d5f7e61e7de8.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=60b61efa-419c-4a7c-b887-b0950f1fd7be</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,60b61efa-419c-4a7c-b887-b0950f1fd7be.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,60b61efa-419c-4a7c-b887-b0950f1fd7be.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=60b61efa-419c-4a7c-b887-b0950f1fd7be</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
There were some issues with TimeTrax – Harvest (the Windows Phone 7 application for
the <a href="http://www.getharvest.com/">Harvest time tracking service</a>) related
to culture and time zones.  those users located in a different time zone from
where the web service layer of this application was hosted could experience issues
with what the application perceives as the first day of the week for the user.  
Special thanks to Stephen Price in Perth for helping out in reporting &amp; testing
the app!
</p>
        <p>
In addition, if you were, for example, recording time for May 12, 2011.  The
application was always taking “05/12/2011” to mean just that and did not take culture
into account.  Across the world of course, many people would interpret the above
as December 5th, 2011.  Equally as bad,  today, May 16th, 2011 or 
“05/16/2011” would be interpreted as nonsense :) and cause an error.
</p>
        <p>
So for all you non US Central Time (UTC –6:00) users out there, make sure to get this
latest update from the marketplace!
</p>
        <img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=60b61efa-419c-4a7c-b887-b0950f1fd7be" />
      </body>
      <title>TimeTrax–Harvest v1.3 Released</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,60b61efa-419c-4a7c-b887-b0950f1fd7be.aspx</guid>
      <link>http://blog.davearlin.com/2011/05/16/TimeTraxHarvestV13Released.aspx</link>
      <pubDate>Mon, 16 May 2011 15:51:46 GMT</pubDate>
      <description>&lt;p&gt;
There were some issues with TimeTrax – Harvest (the Windows Phone 7 application for
the &lt;a href="http://www.getharvest.com/"&gt;Harvest time tracking service&lt;/a&gt;) related
to culture and time zones.&amp;nbsp; those users located in a different time zone from
where the web service layer of this application was hosted could experience issues
with what the application perceives as the first day of the week for the user.&amp;nbsp;&amp;nbsp;
Special thanks to Stephen Price in Perth for helping out in reporting &amp;amp; testing
the app!
&lt;/p&gt;
&lt;p&gt;
In addition, if you were, for example, recording time for May 12, 2011.&amp;nbsp; The
application was always taking “05/12/2011” to mean just that and did not take culture
into account.&amp;nbsp; Across the world of course, many people would interpret the above
as December 5th, 2011.&amp;nbsp; Equally as bad,&amp;nbsp; today, May 16th, 2011 or&amp;nbsp;
“05/16/2011” would be interpreted as nonsense :) and cause an error.
&lt;/p&gt;
&lt;p&gt;
So for all you non US Central Time (UTC –6:00) users out there, make sure to get this
latest update from the marketplace!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=60b61efa-419c-4a7c-b887-b0950f1fd7be" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,60b61efa-419c-4a7c-b887-b0950f1fd7be.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=f540d5d5-a649-496e-b5ca-0005a08855ae</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,f540d5d5-a649-496e-b5ca-0005a08855ae.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,f540d5d5-a649-496e-b5ca-0005a08855ae.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f540d5d5-a649-496e-b5ca-0005a08855ae</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <title>TimeTrax–Harvest for Windows Phone</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,f540d5d5-a649-496e-b5ca-0005a08855ae.aspx</guid>
      <link>http://blog.davearlin.com/2011/04/25/TimeTraxHarvestForWindowsPhone.aspx</link>
      <pubDate>Mon, 25 Apr 2011 17:57:40 GMT</pubDate>
      <description>&lt;h3&gt;It’s Been Awhile
&lt;/h3&gt;
&lt;p&gt;
So wow, it’s almost been a full year since my last post!&amp;nbsp; Over the last few months
now, I’ve been playing with Windows Phone 7 Development.&amp;nbsp; My first app published
under my company, &lt;a href="http://www.triton-tek.com"&gt;Triton-Tek&lt;/a&gt; is called &lt;a href="http://www.appsfuze.com/applications/windowsphone.tools/timetrax-harvest,13267"&gt;TimeTrax
– Harvest&lt;/a&gt;.&amp;nbsp; It’s a Windows Phone client for the &lt;a href="http://www.getharvest.com/"&gt;Harvest&lt;/a&gt; time
tracking service.&amp;nbsp; Also yes, it’s FREE.&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
Harvest already has a number of add-ons, including IPhone and Android mobile applications
as well as a Twitter plug in, Apple and Windows widget, Google Apps plug in and others.&amp;nbsp;
So writing the Windows Phone add-on felt like a fitting idea.
&lt;/p&gt;
&lt;h5&gt;
&lt;/h5&gt;
&lt;h5&gt;
&lt;/h5&gt;
&lt;h3&gt;
&lt;/h3&gt;
&lt;h5&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:66721397-FF69-4ca6-AEC4-17E6B3208830:05638d88-ed43-4cc5-8d16-e14bbcb47683" class="wlWriterEditableSmartContent"&gt;
&lt;table border=0 cellspacing=0 cellpadding=0 style='outline:none;border-style:none;margin:0px;padding:0px;width:410px;border-collapse:collapse;'&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style='margin:0px;padding:0px;outline:none;border-style:none;width:auto'&gt;
&lt;a style="outline:none;border-style:none;margin:0px;padding:0px;" target="_blank" href="https://cid-a26544eb4fb768fd.skydrive.live.com/redir.aspx?page=play&amp;amp;resid=A26544EB4FB768FD!125&amp;amp;type=5&amp;amp;authkey=rwck2B0tdxM%24&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos"&gt;&lt;img style="outline:none;border-style:none;padding:0px;margin:0px;border:0px;background:none;background-image:none;vertical-align:bottom;" alt="View album" title="View album" src="http://blog.davearlin.com/content/binary/Windows-Live-Writer/TimeTraxHarvest-for-Windows-Phone_A63D/TimeTrax%E2%80%93Harvest.jpg" /&gt;&lt;/a&gt;
&lt;div style='width:410px;text-align:center;overflow:visible;padding:0px;margin:0px;'&gt;
&lt;div style='width:410px;overflow:visible;'&gt;&lt;a style="text-decoration:none;" href="https://cid-a26544eb4fb768fd.skydrive.live.com/redir.aspx?page=browse&amp;amp;resid=A26544EB4FB768FD!125&amp;amp;type=5&amp;amp;authkey=rwck2B0tdxM%24&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos" target="_blank"&gt;&lt;span style="line-height:1.26em;padding:0px;width:410px;font-size:26pt;font-family:'Segoe UI', helvetica, arial, sans-serif;" defaulttext="Enter album name here"&gt;TimeTrax&amp;ndash;Harvest&lt;/span&gt;&lt;/a&gt;
&lt;/div&gt;
&lt;div style="text-align:center;padding:9px 0px 0px 0px;margin:0px 0px 0px 0px;font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;"&gt;
&lt;table border=0 cellspacing=0 cellpadding=0 style="text-align:center;width:auto;margin-left:auto;margin-right:auto;padding:0px;outline:none;border-style:none;border-collapse:collapse;"&gt;
&lt;tr&gt;
&lt;td style="vertical-align:top;outline:none;border-style:none;margin:0px;padding:6px 12px 6px 0px;"&gt;
&lt;a href="https://cid-a26544eb4fb768fd.skydrive.live.com/redir.aspx?page=play&amp;amp;resid=A26544EB4FB768FD!125&amp;amp;type=5&amp;amp;authkey=rwck2B0tdxM%24&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;VIEW
SLIDE SHOW&lt;/a&gt;&lt;/td&gt;
&lt;td style="vertical-align:top;outline:none;border-style:none;margin:0px;padding:6px 0px 6px 0px;"&gt;
&lt;a href="https://cid-a26544eb4fb768fd.skydrive.live.com/redir.aspx?page=downloadphotos&amp;amp;resid=A26544EB4FB768FD!125&amp;amp;type=5&amp;amp;Bsrc=Photomail&amp;amp;Bpub=SDX.Photos&amp;amp;authkey=rwck2B0tdxM%24" border="0" target="_blank" style="font-family:'Segoe UI', helvetica, arial, sans-serif;font-size:8pt;outline:none;border-style:none;text-decoration: none;padding:0px;margin:0px;"&gt;DOWNLOAD
ALL&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;/div&gt;
&lt;/h5&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;h3&gt;App Guts - Caliburn.Micro and ASP.NET MVC
&lt;/h3&gt;
&lt;p&gt;
I used the &lt;a href="http://caliburnmicro.codeplex.com/"&gt;Caliburn.Micro&lt;/a&gt; framework
to help out with View/ViewModel binding via convention based application design as
well as to help out with things like in memory and Isolated Storage.&amp;nbsp; It also
makes all server side calls to my ASP.NET MVC web service layer extremely easy through
an exceptionally friendly use of IEnumerable and the Yield keyword.&amp;nbsp; A special
thank you goes out to &lt;a href="http://www.matthidinger.com"&gt;Matt Hidinger&lt;/a&gt;, my
coworker for helping me get hit the ground running with holding my hand thru the various
stages of the development process.&amp;nbsp; You should check out his apps, &lt;a href="http://wp7.apphab.com/bus-watch-chicago-by-matt-hidinger/"&gt;Bus
Watch Chicago&lt;/a&gt; and &lt;a href="http://wp7.apphab.com/transit-directions-by-matt-hidinger/"&gt;Transit
Directions&lt;/a&gt; here.&amp;nbsp; Another thank you goes out to my wife Jamie Arlin of &lt;a href="http://www.jamielynndesigns.com"&gt;Jamie
Lynn Designs&lt;/a&gt; for helping me out with the live tile, application icon and splash
screen artwork!
&lt;/p&gt;
&lt;p&gt;
I built the ASP.NET MVC layer to assist in offloading calls to the &lt;a href="http://www.getharvest.com/api"&gt;Harvest
API&lt;/a&gt;.&amp;nbsp; The Harvest API was extremely easy to work with. It is RESTful supporting
both XML and JSON.&amp;nbsp; My application requires 7 full days of time entries to be
displayed at once.&amp;nbsp; Unfortunately as of now, the Harvest API only allows one
day’s worth of time per HTTP GET request, so 7 total calls to the Harvest API are
required for each week selected.&amp;nbsp;&amp;nbsp; Users on slow phone connections would
not want to wait the amount of time it would take to send and receive back information
for 7 web service calls, so my web service layer instead makes these calls while the
phone client only makes the one.
&lt;/p&gt;
&lt;p&gt;
Another reason for the MVC layer is password encryption.&amp;nbsp; The AES encryption
algorithm is used to encrypt password data.&amp;nbsp; the public encryption key and salt
for this are stored on our web server, so only a single GUID user token is stored
on the client phone.&amp;nbsp; All web service calls from the client to the web service
layer are encrypted via SSL, so security is handled as much as I deemed necessary
for an application that’s only real usage is time entry.
&lt;/p&gt;
&lt;p&gt;
Lastly, I implemented live tile push notification updates to display how many hours
(rounded to the nearest whole number) the user has entered in for the given Monday
thru Sunday week.&amp;nbsp; This was actually not that hard to implement with the help
of some help from &lt;a href="http://wildermuth.com/2011/01/02/Architecting_WP7_-_Part_8_of_10_Toast_Push_Notifications"&gt;Shawn
Wildermuth’s blog post&lt;/a&gt; on the subject.
&lt;/p&gt;
&lt;p&gt;
Again, if you’re a Harvest user, please check out and download the app &lt;a href="http://www.appsfuze.com/applications/windowsphone.tools/timetrax-harvest,13267"&gt;here&lt;/a&gt;.&amp;nbsp; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=f540d5d5-a649-496e-b5ca-0005a08855ae" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,f540d5d5-a649-496e-b5ca-0005a08855ae.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>Caliburn</category>
      <category>Triton-Tek</category>
      <category>Windows Phone</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=915a5fb7-6059-43dd-ace5-635e12347ebb</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,915a5fb7-6059-43dd-ace5-635e12347ebb.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,915a5fb7-6059-43dd-ace5-635e12347ebb.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=915a5fb7-6059-43dd-ace5-635e12347ebb</wfw:commentRss>
      <title>Simple Tip for Accessing Relative Path Items in Javascript in your ASP.NET Website</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,915a5fb7-6059-43dd-ace5-635e12347ebb.aspx</guid>
      <link>http://blog.davearlin.com/2010/05/03/SimpleTipForAccessingRelativePathItemsInJavascriptInYourASPNETWebsite.aspx</link>
      <pubDate>Mon, 03 May 2010 14:54:25 GMT</pubDate>
      <description>&lt;p&gt;
One common problem I’ve faced when developing applications is when I need to access
an Image file or some other artifact that is relative to my website.
&lt;/p&gt;
&lt;p&gt;
I’ve often gotten “lucky” where my virtual directory path locally matches my QA, Staging,
Production, etc. So I’m able to have javascript code like this:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0062998b-391c-47d2-92a9-d6cd0190ff53" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
$(&lt;span style="color:#a31515"&gt;'.ok-button'&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;, &lt;span style="color:#a31515"&gt;'/Content/Images/btn_ok.jpg'&lt;/span&gt;);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
$(&lt;span style="color:#a31515"&gt;'.ok-button'&lt;/span&gt;).hover(&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() { $(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;, &lt;span style="color:#a31515"&gt;'/Content/Images/btn_okOver.jpg'&lt;/span&gt;);
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
, &lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() { $(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;, &lt;span style="color:#a31515"&gt;'/Content/Images/btn_ok.jpg'&lt;/span&gt;);
}&lt;/li&gt;
&lt;li&gt;
);&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Here, I’m assuming that my images will always be stored somehow like this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://localhost/Content/Images"&gt;http://localhost/Content/Images&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://[test-dns]/Content/Images"&gt;http://[test-dns]/Content/Images&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://[prod-dns]/Content/Images"&gt;http://[prod-dns]/Content/Images&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
etc…
&lt;/p&gt;
&lt;p&gt;
That above javascript will fail if I am forced to be put into a Virtual Directory
such as this:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://[prod-dns]/[some-virtual-directory]/Content/Images"&gt;http://[prod-dns]/[some-virtual-directory]/Content/Images&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
The most effective way I’ve found to get around this is by creating a hidden field
on my main master page that contains the value derived by the web server of the root
URL to my website. This root URL might contain no virtual directory or 10 virtual
directories depending on the IIS Web Server set up.
&lt;/p&gt;
&lt;p&gt;
I’m using ASP.NET MVC, but this example can easily be ported into a Page_Load event
with standard ASP.NET web forms.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:52f40903-a23d-4f2e-87fc-e84a8355e13c" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; virtualPath = &lt;span style="color:#2b91af"&gt;HttpRuntime&lt;/span&gt;.AppDomainAppVirtualPath;&lt;/li&gt; &lt;li style="background: #f3f3f3"&gt;       virtualPath = virtualPath.EndsWith(&lt;span style="color:#a31515"&gt;"/"&lt;/span&gt;) ? virtualPath : virtualPath + &lt;span style="color:#a31515"&gt;"/"&lt;/span&gt;;&lt;/li&gt; &lt;li&gt;    &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;id&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"website-image-path"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"hidden"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;value&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;'&lt;/span&gt;&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;=virtualPath + "Content/Images/" &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;&lt;span style="color:#0000ff"&gt;'&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
Just place that code somewhere in the body of your master page.
&lt;/p&gt;
&lt;p&gt;
Then access it via JQuery, or standard javascript using something like this:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:a6c111d5-273d-4979-a992-ad2e0a7295b7" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
$(&lt;span style="color:#a31515"&gt;'#website-image-path'&lt;/span&gt;).val();&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Then finally you’re javascript might look something like this to get at your actual
Image source.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0e8449dc-9e89-4ec4-8e2c-2be80e91fffe" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; websiteImagePath = $(&lt;span style="color:#a31515"&gt;'#website-image-path'&lt;/span&gt;).val();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
$(&lt;span style="color:#a31515"&gt;'.ok-button'&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;,
websiteImagePath + &lt;span style="color:#a31515"&gt;'btn_ok.jpg'&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
$(&lt;span style="color:#a31515"&gt;'.ok-button'&lt;/span&gt;).hover(&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() { $(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;,
websiteImagePath + &lt;span style="color:#a31515"&gt;'btn_okOver.jpg'&lt;/span&gt;); }&lt;/li&gt;
&lt;li&gt;
, &lt;span style="color:#0000ff"&gt;function&lt;/span&gt;() { $(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt;).attr(&lt;span style="color:#a31515"&gt;'src'&lt;/span&gt;,
websiteImagePath + &lt;span style="color:#a31515"&gt;'btn_ok.jpg'&lt;/span&gt;); }&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
);&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=915a5fb7-6059-43dd-ace5-635e12347ebb" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,915a5fb7-6059-43dd-ace5-635e12347ebb.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>Deployment</category>
      <category>JQuery</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=51f1b932-abc5-441c-a251-fd9e76a3130b</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=51f1b932-abc5-441c-a251-fd9e76a3130b</wfw:commentRss>
      <title>A Simple Extension of ASP.NET MVC HTMLHelper</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</guid>
      <link>http://blog.davearlin.com/2010/05/01/ASimpleExtensionOfASPNETMVCHTMLHelper.aspx</link>
      <pubDate>Sat, 01 May 2010 03:17:20 GMT</pubDate>
      <description>&lt;p&gt;
If you’re an ASP.NET MVC developer, you’ve almost undoubtedly used HTML helpers, or
at least the built in ones.
&lt;/p&gt;
&lt;p&gt;
Here’s are some common ones:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:dd5bed22-7ed2-403a-bfb6-3240e8b79eca" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.DropDownList(&lt;span style="color:#a31515"&gt;"Countries"&lt;/span&gt;,&lt;span style="color:#a31515"&gt;"Choose Country"&lt;/span&gt;)&lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
This generates a DropDownList populated with the property “Countries” of type “SelectList”
on the ViewData model passed into the view.
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:51c88f73-5b3f-4406-9cd9-1f530966da05" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.TextBox(&lt;span style="color:#a31515"&gt;"EntitySearch"&lt;/span&gt;)&lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
This generates a TextBox bound to the property “EntitySearch” on the ViewData model
passed into the view. Can also be used to populate a property with the same name upon
a form post.
&lt;/p&gt;
&lt;p&gt;
In my current project, I’ve found the need to have many different buttons. These buttons
are custom in the sense that they aren’t the standard HTML buttons, they have CSS
and/or images associated with them. Here’s how I might declare a couple of them right
now:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:0b9ca86d-91c9-45c3-8435-2c5673dfd48d" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;input&lt;/span&gt; &lt;span style="color:#ff0000"&gt;type&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"image"&lt;/span&gt; &lt;span style="color:#ff0000"&gt;class&lt;/span&gt; &lt;span style="color:#0000ff"&gt;=&lt;/span&gt; &lt;span style="color:#0000ff"&gt;"addnew-button"&lt;/span&gt; &lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e9bf5f35-42a4-4c41-a11e-a44cddd9e09a" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.SubmitImage(&lt;span style="color:#a31515"&gt;"Submit"&lt;/span&gt;,&lt;span style="color:#a31515"&gt;"~/images/submit-button.png"&lt;/span&gt;) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
So in both cases, I have to type in a string that kind of defines my button. In the
first example, I have to say my button is an “image” and the class to use to style
the button is called “addnew-button”. 
&lt;/p&gt;
&lt;p&gt;
In the second case, I have to define the actual path to the button. It’d be nice to
have a more common and type safe way to declare all of my buttons, so I’ve created
a Button HtmlHelper method. My goal is to be able to have code in my view like this:
&lt;/p&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e39b116f-0af4-4342-85f3-105801b63541" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.Button(&lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;.&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.AddNew) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:864e5d23-a0c8-4be6-890a-2fac78aea2e9" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="background:#ffee62"&gt;&lt;%&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;Html.Button(&lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;.&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Submit) &lt;span style="background:#ffee62"&gt;%&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
To do this, I created an extension method on the HtmlHelper class called button. This
extension method can handle all my button types and has some overloads to accept a
client id and any additional custom styling.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:c011331e-a3bc-4b87-b9e4-173928a1ff9c" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;namespace&lt;/span&gt; MyProject.HtmlHelpers&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonHtmlHelper&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;enum&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; {
AddNew, Remove, Ok, Cancel, Submit, Save, Search, Clear, Continue, Active, Inactive
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Button(htmlHelper, buttonType, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; id)&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Button(htmlHelper, buttonType, id, &lt;span style="color:#0000ff"&gt;null&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; Button(&lt;span style="color:#0000ff"&gt;this&lt;/span&gt; &lt;span style="color:#2b91af"&gt;HtmlHelper&lt;/span&gt; htmlHelper, &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; id, &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; inlineCSS)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#2b91af"&gt;StringBuilder&lt;/span&gt; addNewButtonHTML = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;StringBuilder&lt;/span&gt;();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;@"&lt;input class= """&lt;/span&gt;);
&lt;/li&gt;
&lt;li&gt;
addNewButtonHTML.Append(GetButtonTypeCSSClassPrefix(buttonType));&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;@"-button"" type = ""image"" "&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(id))&lt;/li&gt;
&lt;li&gt;
addNewButtonHTML.AppendFormat(&lt;span style="color:#a31515"&gt;@"id = ""{0}"" "&lt;/span&gt;,
id);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;if&lt;/span&gt; (!&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.IsNullOrEmpty(inlineCSS))&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.AppendFormat(&lt;span style="color:#a31515"&gt;@"style = ""{0}"" "&lt;/span&gt;,
inlineCSS);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
addNewButtonHTML.Append(&lt;span style="color:#a31515"&gt;"/&gt;"&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; addNewButtonHTML.ToString();&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; GetButtonTypeCSSClassPrefix(&lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt; buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;switch&lt;/span&gt; (buttonType)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.AddNew:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"addnew"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Cancel:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"cancel"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Ok:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"ok"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Remove:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"remove"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Submit:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"submit"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Save:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"save"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Search:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"search"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Clear:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"clear"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Continue:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"continue"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Active:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"active"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;case&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ButtonType&lt;/span&gt;.Inactive:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#a31515"&gt;"inactive"&lt;/span&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;default&lt;/span&gt;:&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;throw&lt;/span&gt; &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ArgumentException&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;.Format(&lt;span style="color:#a31515"&gt;"Unknown
ButtonType of {0} was passed in."&lt;/span&gt;, buttonType));&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
That’s all! Just make sure you either add a using statement on the view to the namespace
where the HTMLHelper is, or put it in the web.config like I did in my project. (line
10)
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:9551f6e6-3c3d-4700-972a-a56682c04e0a" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;namespaces&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc.Ajax&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Mvc.Html&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Web.Routing&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Linq&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;System.Collections.Generic&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;Microsoft.Web.Mvc&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;xVal.Html&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;&lt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;add&lt;/span&gt;&lt;span style="color:#0000ff"&gt; &lt;/span&gt;&lt;span style="color:#ff0000"&gt;namespace&lt;/span&gt;&lt;span style="color:#0000ff"&gt;=&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;MyProject.HtmlHelpers&lt;/span&gt;"&lt;span style="color:#0000ff"&gt;/&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;&lt;/span&gt;&lt;span style="color:#a31515"&gt;namespaces&lt;/span&gt;&lt;span style="color:#0000ff"&gt;&gt;&lt;/span&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=51f1b932-abc5-441c-a251-fd9e76a3130b" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,51f1b932-abc5-441c-a251-fd9e76a3130b.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>HTMLHelper</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=9b5c9cd4-190d-48fe-af70-2d269636653c</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,9b5c9cd4-190d-48fe-af70-2d269636653c.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,9b5c9cd4-190d-48fe-af70-2d269636653c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=9b5c9cd4-190d-48fe-af70-2d269636653c</wfw:commentRss>
      <title>JSON to .NET Object Using JQuery and IModelBinder in ASP.NET MVC</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,9b5c9cd4-190d-48fe-af70-2d269636653c.aspx</guid>
      <link>http://blog.davearlin.com/2010/04/30/JSONToNETObjectUsingJQueryAndIModelBinderInASPNETMVC.aspx</link>
      <pubDate>Fri, 30 Apr 2010 03:15:59 GMT</pubDate>
      <description>&lt;p&gt;
Ok, so I have a pretty basic web page that displays a paginated grid of a collection
of my business objects. This grid gets displayed when I perform a simple string search
on let’s say my entity name. Of course, everyone hates dealing with full postbacks,
so I want to perform this search via javascript, or more specifically via an AJAX
call. 
&lt;/p&gt;
&lt;p&gt;
Using the typical form post method common in many ASP.NET MVC applications doesn’t
really work in my scenario because I’m not mapping all the necessary fields upon landing
on my page. 
&lt;/p&gt;
&lt;p&gt;
I know I want to use JQuery’s AJAX capabilities to post my search string information,
but I couldn’t figure out a way to do it without passing in an “ugly” set of query
strings and having to accept 3 parameters in my Controller Action method. 
&lt;/p&gt;
&lt;p&gt;
Basically I didn’t want to have to have something like this:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:678ff489-ffa0-412f-8c3b-5be55d5d0c61" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
[&lt;span style="color:#2b91af"&gt;NoCache&lt;/span&gt;][&lt;span style="color:#2b91af"&gt;AcceptVerbs&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;HttpVerbs&lt;/span&gt;.Post)]&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ActionResult&lt;/span&gt; SearchEntities(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; searchValue, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; pageNumber, &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; itemsPerPage)&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; allSearchResults = _entityAdministrationService.SearchEntities(searchValue);&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchResultsForPage = allSearchResults.Skip((pageNumber
- 1) * itemsPerPage).Take(itemsPerPage);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Json(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EntitySearchResultsInput&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
Entities = searchResultsForPage,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
ItemsPerPage = itemsPerPage,&lt;/li&gt;
&lt;li&gt;
PageNumber = pageNumber,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
TotalResults = allSearchResults.Count()&lt;/li&gt;
&lt;li&gt;
});&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
(oh by the way, going forward in this post, ignore my custom “NoCache” attribute in
any of my code snippets. It’s not related to this post, but I use it all the time
now because of the automatic post caching feature in IE).
&lt;/p&gt;
&lt;p&gt;
Ok, so if you look at the method signature, it really doesn’t look THAT bad right?
Well it’s not bad, but the problem is that I’m sure I’ll have other pages that need
to perform AJAX calls that will pass in other sets of parameters. I want one to have
a nice POCO that I can work with that gets “automatically” mapped for me. 
&lt;/p&gt;
&lt;p&gt;
I want something like this:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3db425a3-c600-4170-ad9a-ec777f234678" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
[&lt;span style="color:#2b91af"&gt;NoCache&lt;/span&gt;][&lt;span style="color:#2b91af"&gt;AcceptVerbs&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;HttpVerbs&lt;/span&gt;.Post)]&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ActionResult&lt;/span&gt; SearchEntities(&lt;span style="color:#2b91af"&gt;EntitySearchOutput&lt;/span&gt; entitySearchOutput)&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; allSearchResults = _entityAdministrationService.SearchEntities(entitySearchOutput.SearchValue);&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchResultsForPage = allSearchResults.Skip((entitySearchOutput.PageNumber
- 1) * entitySearchOutput.ItemsPerPage).Take(entitySearchOutput.ItemsPerPage);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Json(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EntitySearchResultsInput&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
Entities = searchResultsForPage,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
ItemsPerPage = entitySearchOutput.ItemsPerPage,&lt;/li&gt;
&lt;li&gt;
PageNumber = entitySearchOutput.PageNumber,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
TotalResults = allSearchResults.Count()&lt;/li&gt;
&lt;li&gt;
});&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Where the definition of EntitySearchOutput is:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:67f16ba9-013c-4c10-895a-1d0b9cb35374" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EntitySearchOutput&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;string&lt;/span&gt; SearchValue
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; PageNumber
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; ItemsPerPage
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So, making use of Google’s &lt;a href="http://code.google.com/p/jquery-json/"&gt;jquery.json
library&lt;/a&gt;, and javascript objects, I’m able to write the following javascript code
that calls my “SearchEntities” controller action.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:3d5ce4f5-729d-470e-9d40-f71b9c21a6db" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchValue = GetSearchValue();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; currentPageNumber = GetCurrentPageNumber();&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; itemsPerPage = 20;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchData = {&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'SearchValue'&lt;/span&gt;: searchValue,&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#a31515"&gt;'PageNumber'&lt;/span&gt;: currentPageNumber,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'ItemsPerPage'&lt;/span&gt;: itemsPerPage&lt;/li&gt;
&lt;li&gt;
};&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchDataJSON = $.toJSON(searchData);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
searchDataJSON = searchDataJSON.replace(/&lt;span style="color:#0000ff"&gt;null&lt;/span&gt;/g, &lt;span style="color:#a31515"&gt;''&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
$.post(&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'../ApplicationManagement/SearchEntities'&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;
{ EntitySearchOutput: searchDataJSON },&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;(jsonResult) {&lt;/li&gt;
&lt;li&gt;
DisplaySearchResults(jsonResult);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}, &lt;span style="color:#a31515"&gt;"json"&lt;/span&gt;);&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So what this actually does is builds out my “searchData” javascript object and then
runs through the “$.toJSON” function to convert the javascript object to a JSON object
called “searchDataJSON”. This in turn gets passed to my “SearchEntities” method as
a JSON string. As a side note, line 12 is necessary for IE so that the JSON string
gets created in a way that can be de-serialized by .NETs JavascriptSerializer as you’ll
see soon.
&lt;/p&gt;
&lt;p&gt;
So how does the application know to convert what I passed in javascript to my EntitySearchOutput
class? That’s where an IModelBinder implementation comes into play.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ed1f2cbf-8251-4919-81a6-0a89b376d3e5" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 500px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;JsonModelBinder&lt;/span&gt;
&lt;T&gt;
:&lt;span style="color:#2b91af"&gt;IModelBinder&lt;/span&gt; &lt;span style="color:#0000ff"&gt;where&lt;/span&gt; T:&lt;span style="color:#0000ff"&gt;class&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; IModelBinder Members&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; BindModel(&lt;span style="color:#2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext, &lt;span style="color:#2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; jsonString = controllerContext.RequestContext.HttpContext.Request.Params[0];&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#2b91af"&gt;JavaScriptSerializer&lt;/span&gt; serializer = &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;JavaScriptSerializer&lt;/span&gt;();&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; result = serializer.DeserializeObject(jsonString);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; serializer.ConvertToType&lt;T&gt;
(result);
&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
As you can see, this JsonModelBinder class does not say anything about EntitySearchOutput.
As a matter of fact, it is a generic class which means, yes, it can be used for any
class provided it is Javascript serializable. So you can do this with deep complex
arrays. The one method you must implement is called “BindModel” which gives you a
reference to the HttpContext. The json String exists in the HttpContext.Request parameter.
Simple use the JavaScriptSerializer framework class and deserialize to the generic
type T and return the results.
&lt;/p&gt;
&lt;p&gt;
The final piece of this to tie in the model binder comes in the Global.asax.cs 
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:7e48d0d2-1a18-401e-8f97-6774a28f6e00" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;protected&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; Application_Start()&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
RegisterRoutes(&lt;span style="color:#2b91af"&gt;RouteTable&lt;/span&gt;.Routes);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
SetupIoCContainer(); 
&lt;/li&gt;
&lt;li&gt;
SetupModelBinders(); 
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;li&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;private&lt;/span&gt; &lt;span style="color:#0000ff"&gt;static&lt;/span&gt; &lt;span style="color:#0000ff"&gt;void&lt;/span&gt; SetupModelBinders()&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#2b91af"&gt;ModelBinders&lt;/span&gt;.Binders.Add(&lt;span style="color:#0000ff"&gt;typeof&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;EntitySearchOutput&lt;/span&gt;), &lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;JsonModelBinder&lt;/span&gt;&lt;&lt;span style="color:#2b91af"&gt;EntitySearchOutput&gt;&gt;());&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The “SetupModelBinders” method makes a call that tells the MVC Framework to always
using the JsonModelBinder class to create an EntitySearchOutput object when it is
specified as a parameter of a controller action. 
&lt;/p&gt;
&lt;p&gt;
Now the controller action will work as expected:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:34d13e1a-27ce-4db2-8440-c67308133009" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
[&lt;span style="color:#2b91af"&gt;NoCache&lt;/span&gt;][&lt;span style="color:#2b91af"&gt;AcceptVerbs&lt;/span&gt;(&lt;span style="color:#2b91af"&gt;HttpVerbs&lt;/span&gt;.Post)]&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;ActionResult&lt;/span&gt; SearchEntities(&lt;span style="color:#2b91af"&gt;EntitySearchOutput&lt;/span&gt; entitySearchOutput)&lt;/li&gt;
&lt;li&gt;
{&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; allSearchResults = _entityAdministrationService.SearchEntities(entitySearchOutput.SearchValue);&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchResultsForPage = allSearchResults.Skip((entitySearchOutput.PageNumber
- 1) * entitySearchOutput.ItemsPerPage).Take(entitySearchOutput.ItemsPerPage);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; Json(&lt;span style="color:#0000ff"&gt;new&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EntitySearchResultsInput&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
Entities = searchResultsForPage,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
ItemsPerPage = entitySearchOutput.ItemsPerPage,&lt;/li&gt;
&lt;li&gt;
PageNumber = entitySearchOutput.PageNumber,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
TotalResults = allSearchResults.Count()&lt;/li&gt;
&lt;li&gt;
});&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
The final part of this method returns back JSON to our javascript AJAX call, it JSON
serializes an “EntitySearchResultsInput” class defined here:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ec4dc431-f999-4293-bced-8510ef0b1b0e" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;EntitySearchResultsInput&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#2b91af"&gt;IEnumerable&lt;/span&gt;&lt;&lt;span style="color:#2b91af"&gt;Entity&gt;&gt;
Entities { &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; ItemsPerPage
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; PageNumber
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt; TotalResults
{ &lt;span style="color:#0000ff"&gt;get&lt;/span&gt;; &lt;span style="color:#0000ff"&gt;set&lt;/span&gt;;
}&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So that the following “jsonResult” object is populated on line 17 below:
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:ef90e839-3e93-4ca8-979b-ab5b8ae8280f" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #ddd; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0 0 0 2.5em; padding: 0 0 0 5px;"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchValue = GetSearchValue();&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; currentPageNumber = GetCurrentPageNumber();&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; itemsPerPage = 20;&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchData = {&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'SearchValue'&lt;/span&gt;: searchValue,&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#a31515"&gt;'PageNumber'&lt;/span&gt;: currentPageNumber,&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'ItemsPerPage'&lt;/span&gt;: itemsPerPage&lt;/li&gt;
&lt;li&gt;
};&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;var&lt;/span&gt; searchDataJSON = $.toJSON(searchData);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
searchDataJSON = searchDataJSON.replace(/&lt;span style="color:#0000ff"&gt;null&lt;/span&gt;/g, &lt;span style="color:#a31515"&gt;''&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
$.post(&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#a31515"&gt;'../ApplicationManagement/SearchEntities'&lt;/span&gt;,&lt;/li&gt;
&lt;li&gt;
{ EntitySearchOutput: searchDataJSON },&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;function&lt;/span&gt;(jsonResult) {&lt;/li&gt;
&lt;li&gt;
DisplaySearchResults(jsonResult);&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}, &lt;span style="color:#a31515"&gt;"json"&lt;/span&gt;);&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
You can access properties on “jsonResult” simply by typing in: jsonResult.TotalResults
or jsonResult.Entities[0].Name
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So that’s an example of one implementation of IModelBinder. You might find other things
you want to do with other types of ModelBinders. I actually created another one for
a specific scenario I had with arrays of integers. Here is that ModelBinder. I’ll
leave it to you to see how you might use it.
&lt;/p&gt;
&lt;div style="padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px" id="scid:9ce6104f-a9aa-4a17-a79f-3a39532ebf7c:e564b8e0-7677-4e8f-9967-06b76e594df1" class="wlWriterEditableSmartContent"&gt;
&lt;div style="border: #000080 1px solid; color: #000; font-family: 'Courier New', Courier, Monospace; font-size: 10pt"&gt;
&lt;div style="background: #fff; max-height: 300px; overflow: auto"&gt;
&lt;ol style="background: #ffffff; margin: 0; padding: 0 0 0 5px; white-space: nowrap"&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;class&lt;/span&gt; &lt;span style="color:#2b91af"&gt;CommaSeperatedStringToIntegerEnumModelBinder&lt;/span&gt; : &lt;span style="color:#2b91af"&gt;IModelBinder&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;#region&lt;/span&gt; IModelBinder Members&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;public&lt;/span&gt; &lt;span style="color:#0000ff"&gt;object&lt;/span&gt; BindModel(&lt;span style="color:#2b91af"&gt;ControllerContext&lt;/span&gt; controllerContext, &lt;span style="color:#2b91af"&gt;ModelBindingContext&lt;/span&gt; bindingContext)&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
{&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; commaSeperatedString = controllerContext.RequestContext.HttpContext.Request.Params[&lt;span style="color:#a31515"&gt;"Ids"&lt;/span&gt;];&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;string&lt;/span&gt;[] intStringArray = commaSeperatedString.Split(&lt;span style="color:#a31515"&gt;','&lt;/span&gt;);&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#2b91af"&gt;IEnumerable&lt;/span&gt;&lt;&lt;span style="color:#0000ff"&gt;int&gt;&lt;&lt;span style="color:#0000ff"&gt;&gt;
intArray = intStringArray.ToList().ConvertAllint&gt;&gt;(&lt;span style="color:#0000ff"&gt;delegate&lt;/span&gt;(&lt;span style="color:#0000ff"&gt;string&lt;/span&gt; str)
{ &lt;span style="color:#0000ff"&gt;return&lt;/span&gt; &lt;span style="color:#0000ff"&gt;int&lt;/span&gt;.Parse(str);
});&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;span style="color:#0000ff"&gt;return&lt;/span&gt; intArray;&lt;/li&gt;
&lt;li&gt;
}&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;span style="color:#0000ff"&gt;#endregion&lt;/span&gt;
&lt;/li&gt;
&lt;li style="background: #f3f3f3"&gt;
}&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=9b5c9cd4-190d-48fe-af70-2d269636653c" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,9b5c9cd4-190d-48fe-af70-2d269636653c.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>IModelBinder</category>
      <category>Inversion of Control (IoC)</category>
      <category>JQuery</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=0c2deede-9c40-423d-b630-a550f2c6b548</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,0c2deede-9c40-423d-b630-a550f2c6b548.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,0c2deede-9c40-423d-b630-a550f2c6b548.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0c2deede-9c40-423d-b630-a550f2c6b548</wfw:commentRss>
      <title>Useful Usage of Microsoft Unity Application Block with ASP.Net MVC</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,0c2deede-9c40-423d-b630-a550f2c6b548.aspx</guid>
      <link>http://blog.davearlin.com/2009/12/25/UsefulUsageOfMicrosoftUnityApplicationBlockWithASPNetMVC.aspx</link>
      <pubDate>Fri, 25 Dec 2009 20:11:14 GMT</pubDate>
      <description>&lt;h1&gt;
&lt;/h1&gt;
&lt;h4&gt;Testing is Always Number One
&lt;/h4&gt;
&lt;p&gt;
If you read any book on why using an &lt;a href="http://en.wikipedia.org/wiki/Inversion_of_control"&gt;IoC
(Inversion of Control)&lt;/a&gt; approach to your website using tools like Microsoft’s &lt;a href="http://msdn.microsoft.com/en-us/library/cc468366.aspx"&gt;Unity
Application Block&lt;/a&gt; and a Mocking Framework like &lt;a href="http://www.ayende.com/"&gt;Rhino
Mocks&lt;/a&gt;, the number one reason is going to be writing solid unit tests, usually
using a practice like TDD. While I have no reason to doubt that that should be the
number one reason, I like to always try and find more “live and in the moment” scenarios
for using these tools. 
&lt;/p&gt;
&lt;p&gt;
Here’s a very common testing scenario and implementation for testing that the &lt;a href="http://google.com/analytics"&gt;Google
Analytics&lt;/a&gt; javascript is only appearing in my site if I am in a Production environment.
This makes also makes use of &lt;a href="http://www.codeplex.com/MVCContrib"&gt;MvcContrib&lt;/a&gt;.
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="715"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="713"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;using &lt;/span&gt;System; &lt;span style="color: blue"&gt;using &lt;/span&gt;System.Collections.Generic; &lt;span style="color: blue"&gt;using &lt;/span&gt;System.Linq; &lt;span style="color: blue"&gt;using &lt;/span&gt;System.Text; &lt;span style="color: blue"&gt;using &lt;/span&gt;System.Web.Mvc; &lt;span style="color: blue"&gt;using &lt;/span&gt;Microsoft.VisualStudio.TestTools.UnitTesting; &lt;span style="color: blue"&gt;using &lt;/span&gt;MyWebSite.Web; &lt;span style="color: blue"&gt;using &lt;/span&gt;MyWebSite.Web.Controllers; &lt;span style="color: blue"&gt;using &lt;/span&gt;MyWebSite.Services; &lt;span style="color: blue"&gt;using &lt;/span&gt;Rhino.Mocks; &lt;span style="color: blue"&gt;using &lt;/span&gt;MvcContrib.TestHelper;&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public
class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HomeControllerTest &lt;/span&gt;{ &lt;span style="color: #2b91af"&gt;IAppConfig &lt;/span&gt;_appConfig; &lt;span style="color: #2b91af"&gt;IEmailService &lt;/span&gt;_emailService; &lt;span style="color: #2b91af"&gt;HomeController &lt;/span&gt;_homeController;
[&lt;span style="color: #2b91af"&gt;TestInitialize&lt;/span&gt;] &lt;span style="color: blue"&gt;public
void &lt;/span&gt;Init() { _appConfig = &lt;span style="color: #2b91af"&gt;MockRepository&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;.GenerateStubIAppConfig&gt;&gt;();
_emailService = &lt;span style="color: #2b91af"&gt;MockRepository&lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;.GenerateStubIEmailService&gt;&gt;();
_homeController = &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;HomeController&lt;/span&gt;(_appConfig,
_emailService); &lt;span style="color: #2b91af"&gt;TestControllerBuilder &lt;/span&gt;builder
= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;TestControllerBuilder&lt;/span&gt;();
builder.InitializeController(_homeController); } [&lt;span style="color: #2b91af"&gt;TestMethod&lt;/span&gt;] &lt;span style="color: blue"&gt;public
void &lt;/span&gt;Analytics_NotProduction() { &lt;span style="color: green"&gt;// Arrange &lt;/span&gt;_appConfig.Stub(a
=&gt; a.Environment).Return(&lt;span style="color: #a31515"&gt;"Staging"&lt;/span&gt;); &lt;span style="color: green"&gt;//
Act &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EmptyResult &lt;/span&gt;result = _homeController.Analytics() &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;EmptyResult&lt;/span&gt;; &lt;span style="color: green"&gt;//
Assert &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(result); } [&lt;span style="color: #2b91af"&gt;TestMethod&lt;/span&gt;] &lt;span style="color: blue"&gt;public
void &lt;/span&gt;Analytics_Production() { &lt;span style="color: green"&gt;// Arrange &lt;/span&gt;_appConfig.Stub(a
=&gt; a.Environment).Return(&lt;span style="color: #a31515"&gt;"Production"&lt;/span&gt;); &lt;span style="color: green"&gt;//
Act &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ViewResult &lt;/span&gt;result = _homeController.Analytics() &lt;span style="color: blue"&gt;as &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ViewResult&lt;/span&gt;; &lt;span style="color: green"&gt;//
Assert &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Assert&lt;/span&gt;.IsNotNull(result); } }&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
So here, my HomeController class’ constructor needs an instance of both IEmailService
and IAppConfig. Rhino Mocks creates a mock of both of those interfaces and additionally
sets the “Environment” property of the mocked IAppConfig instance to either “Staging”
or “Production” depending on my test. 
&lt;/p&gt;
&lt;p&gt;
In the “Analytics_NotProduction” test, my test passes if an “EmptyResult” instance
is returned by my HomeController’s Analytics method meaning that no View is generated
with any markup or javascript of any kind. The “Analytics_Production” test passes
if the Analytics method returns an actual ViewResult which presumably generates the
javascript I need for Google Analytics.
&lt;/p&gt;
&lt;p&gt;
Again, this is just your typical unit test scenario. This is great, you should do
this. I should do this more than I do right now with my projects. That’s another story.
Here’s another quick and easy (and also immediately useful) scenario I’ve come up
with for using IoC.
&lt;/p&gt;
&lt;h5&gt;
&lt;/h5&gt;
&lt;h4&gt;Shared Hosting Limitations with a Staging and Production Environment
&lt;/h4&gt;
&lt;p&gt;
So recently, I’ve begun working on my wife’s business website, &lt;a href="http://jamieldesigns.com"&gt;Jamie
Lynn Designs&lt;/a&gt;. This website is currently hosted using &lt;a href="http://www.softsyshosting.com/"&gt;Softsys
Hosting’s Shared Hosting&lt;/a&gt;. &lt;font color="#006200"&gt;/* End shameful social marketting
plug */&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
On this website, random quotes are displayed from my wife’s happy customers. Every
time you load up a page, another random quote displays. These quotes are stored in
a SQL Database. 
&lt;/p&gt;
&lt;p&gt;
Snippet from &lt;strong&gt;HomeController.cs&lt;/strong&gt;
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="730"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="728"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt; private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IAppConfig &lt;/span&gt;_appConfig; &lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IClientQuoteService &lt;/span&gt;_clientQuoteService; &lt;span style="color: blue"&gt;private &lt;/span&gt;&lt;span style="color: #2b91af"&gt;IContactSubmissionService &lt;/span&gt;_contactSubmissionService; &lt;span style="color: blue"&gt;public &lt;/span&gt;HomeController(&lt;span style="color: #2b91af"&gt;IAppConfig &lt;/span&gt;appConfig, &lt;span style="color: #2b91af"&gt;IContactSubmissionService &lt;/span&gt;contactSubmissionService, 
&lt;br&gt;
&lt;span style="color: #2b91af"&gt;IClientQuoteService &lt;/span&gt;clientQuoteService) { _appConfig
= appConfig; _contactSubmissionService = contactSubmissionService; _clientQuoteService
= clientQuoteService; }&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ActionResult &lt;/span&gt;RandomQuote()
{ &lt;span style="color: #2b91af"&gt;ClientQuote &lt;/span&gt;clientQuote = _clientQuoteService.GetRandomClientQuote(); &lt;span style="color: blue"&gt;return &lt;/span&gt;View(clientQuote);
}&lt;/pre&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;span style="color: blue"&gt; &lt;/span&gt;As you see, in the “RandomQuote” method, there is
a call to the IClientQuoteService’s “GetRandomClientQuote” method. Using Unity, a
concrete implementation of this interface called “ClientQuoteService” is used.
&lt;/p&gt;
&lt;p&gt;
Snippet from &lt;strong&gt;ClientQuoteService.cs&lt;/strong&gt;
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="708"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="706"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClientQuoteService&lt;/span&gt;:&lt;span style="color: #2b91af"&gt;IClientQuoteService &lt;/span&gt;{ &lt;span style="color: #2b91af"&gt;IRepository &lt;/span&gt;_repository; &lt;span style="color: blue"&gt;public &lt;/span&gt;ClientQuoteService(&lt;span style="color: #2b91af"&gt;IRepository &lt;/span&gt;repository)
{ _repository = repository; } &lt;span style="color: blue"&gt;#region &lt;/span&gt;IClientQuoteService
Members &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClientQuote &lt;/span&gt;GetRandomClientQuote()
{ &lt;span style="color: blue"&gt;int &lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;clientQuoteCount
= _repository.GetAllClientQuote&gt;&gt;().Count(); &lt;span style="color: blue"&gt;int &lt;/span&gt;clientQuoteIndex
= &lt;span style="color: blue"&gt;new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;Random&lt;/span&gt;().Next(clientQuoteCount); &lt;span style="color: blue"&gt;return &lt;/span&gt;&lt;&lt;span style="color: #2b91af"&gt;_repository.GetAllClientQuote&gt;&gt;().Skip(clientQuoteIndex).First();
} &lt;span style="color: blue"&gt;#endregion &lt;/span&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt; 
&lt;p&gt;
&lt;p&gt;
This website currently lives in 3 different environments. My local (development) environment,
a Staging Environment also hosted by Softsys Hosting, and the Production Environment.
Since I’m limited to a certain number of databases with my shared hosting plan, I
didn’t want to go and create a Staging database for the website. I was trying to think
of some ways to “physically” handle this problem. 
&lt;p&gt;
&lt;p&gt;
First, I thought about using the Production database for Staging and just creating
“Staging” tables that mimicked production. So if I had a “ClientQuote” table in Production,
I could have a “Staging_ClientQuote” table for Staging. Doing that would be wrong
on so many levels. The most annoying being database migrations and creating different
entity classes for all my database tied entities. 
&lt;p&gt;
&lt;p&gt;
So instead, I stepped back and looked at what was really going on in my application
to generate these quotes. The only thing my HomeController needed in it’s RandomQuote
method was an instance of “ClientQuote”. What I really needed to do was provide an
alternative way to get this quote in an environment that doesn’t use a database. I
needed ANOTHER concrete class to be used in my staging environment. Enter StagingClientQuoteService. 
&lt;p&gt;
&lt;p&gt;
Snippet from &lt;strong&gt;StagingClientQuoteService.cs&lt;/strong&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="700"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="698"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;public class &lt;/span&gt;&lt;span style="color: #2b91af"&gt;StagingClientQuoteService &lt;/span&gt;: &lt;span style="color: #2b91af"&gt;IClientQuoteService &lt;/span&gt;{ &lt;span style="color: blue"&gt;#region &lt;/span&gt;IClientQuoteService
Members &lt;span style="color: blue"&gt;public &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClientQuote &lt;/span&gt;GetRandomClientQuote()
{ &lt;span style="color: blue"&gt;return new &lt;/span&gt;&lt;span style="color: #2b91af"&gt;ClientQuote &lt;/span&gt;{
City = &lt;span style="color: #a31515"&gt;"Chicago"&lt;/span&gt;, Id = 1, Quote = &lt;span style="color: #a31515"&gt;"Jamie
Lynn Designs is really amazing! What else can I say?"&lt;/span&gt;, State = &lt;span style="color: #a31515"&gt;"IL"&lt;/span&gt;,
SubmittedBy = &lt;span style="color: #a31515"&gt;"Dave" &lt;/span&gt;}; } &lt;span style="color: blue"&gt;#endregion &lt;/span&gt;}&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;p&gt;
So here, I now have a class that just creates the same ClientQuote over and over each
time it is called and returns it. I could’ve gotten more complex and created some
more “database free” random quotes and returned those instead. 
&lt;p&gt;
&lt;p&gt;
Using the extension Unity.Configuration block, I’m able to easily swap between my
“real” ClientQuoteService and StagingClientQuoteService. Below I’m omitting some of
the other Unity Mappings to just show what I did for the IClientQuoteService interface. 
&lt;p&gt;
&lt;p&gt;
&lt;p&gt;
Snippet from PRODUCTION &lt;strong&gt;web.config&lt;/strong&gt; 
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt; 
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="700"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="698"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;unity&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;containers&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;container&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;types&lt;/span&gt;&lt;span style="color: blue"&gt;&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt; &lt;span style="color: #a31515"&gt;type &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;JamieLynnDesigns.Core.Services.IClientQuoteService,JamieLynnDesigns.Core&lt;/span&gt;" &lt;span style="color: red"&gt;mapTo&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;JamieLynnDesigns.Core.Services.ClientQuoteService,JamieLynnDesigns.Core&lt;/span&gt;"&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;types&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;container&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;containers&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;unity&lt;/span&gt;&lt;span style="color: blue"&gt;&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;p&gt;
Snippet from STAGING &lt;strong&gt;web.config&lt;/strong&gt;
&lt;/p&gt;
&lt;table border="1" cellspacing="0" cellpadding="2" width="730"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="728"&gt;
&lt;pre class="code"&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;unity&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;containers&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;container&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;types&lt;/span&gt;&lt;span style="color: blue"&gt;&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&lt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;type &lt;/span&gt;&lt;span style="color: red"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;JamieLynnDesigns.Core.Services.IClientQuoteService,JamieLynnDesigns.Core&lt;/span&gt;" &lt;span style="color: red"&gt;mapTo&lt;/span&gt;&lt;span style="color: blue"&gt;=&lt;/span&gt;"&lt;span style="color: blue"&gt;JamieLynnDesigns.Core.Services.Fake.StagingClientQuoteService,JamieLynnDesigns.Core&lt;/span&gt;"&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;type&lt;/span&gt;&lt;span style="color: blue"&gt;&gt; &lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&lt;span style="color: #a31515"&gt;types&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;container&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;containers&lt;/span&gt;&lt;span style="color: blue"&gt;&lt;/span&gt;&gt; &lt;span style="color: #a31515"&gt;unity&lt;/span&gt;&lt;span style="color: blue"&gt;&gt;&lt;/span&gt;
&lt;/pre&gt;&lt;a href="http://11011.net/software/vspaste"&gt;&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
And that’s it! There are many other scenarios where this kind of thing comes in useful.
The only thing I am watching out for is creating too many of my own “fake” classes,
so my projects don’t come to large with “non production” code. But as long as there’s
a good logical separation, such as a folder named “Staging Mocks” or something of
the sort in your project, you should be okay.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=0c2deede-9c40-423d-b630-a550f2c6b548" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,0c2deede-9c40-423d-b630-a550f2c6b548.aspx</comments>
      <category>ASP.Net MVC</category>
      <category>Inversion of Control (IoC)</category>
      <category>Unity Application Block</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=63fbaf9f-3f22-49a3-9831-cdd36094940c</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,63fbaf9f-3f22-49a3-9831-cdd36094940c.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,63fbaf9f-3f22-49a3-9831-cdd36094940c.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=63fbaf9f-3f22-49a3-9831-cdd36094940c</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <b>My New Endevour for the 2nd decade of
the 21st Century</b>
        <br />
I'm excited to be taking on a new and exciting role in the coordination of <a href="http://ntegrate.net">Ntegrate.NET</a>. <a href="http://ntegrate.net">Ntegrate.NET</a> is
a Microsoft technology conference. It will be located at Hotel Sax and the House of
Blues in downtown Chicago on January 18th and 19th, 2010.<br /><br /><b>About Ntegrate.NET</b><br />
This is an unofficial (whatever that really means) discussion of the event.<br /><a href="http://ntegrate.net">Ntegrate.NET</a> is a community driven event that will
touch on the latest in Microsoft technology. It is designed to show off exciting real
world implementations and to teach others what Microsoft products are out there and
how they can help in a variety of corporate and small business scenarios.  
Attendees will get to stay at the Hotel Sax and attend breakouts convering a variety
of topics.  Additionally, keynote presentations will be presented at the House
of Blues concert hall.  One such presentation will be from <a href="http://www.hanselman.com/">Scott
Hanselman</a>, who I'm extactic to have speak!  Lastly, the <a href="http://ntegrate.net">Ntegrate.NET</a> party
will be on the 2nd evening of the event at the House of Blues!<br /><br /><b>Partners</b><br />
I'm more than greatful for all the support I've been getting so far.  This includes
Microsoft, my employer, <a href="http://triton-tek.com">Triton-Tek</a> , and <a href="http://blog.jamieldesigns.com">Jamie
Lynn Designs</a>. There are and probably will be several others who I will be more
than happy to give mention as things progress!<br /><br />
Follow us on <a href="http://twitter.com/NtegrateNET">Twitter </a>and <a href="http://www.facebook.com/group.php?gid=81596219721">Facebook</a>!<br /><p></p><img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=63fbaf9f-3f22-49a3-9831-cdd36094940c" /></body>
      <title>Ntegrate.NET - Jan 18 &amp; 19th - 2010</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,63fbaf9f-3f22-49a3-9831-cdd36094940c.aspx</guid>
      <link>http://blog.davearlin.com/2009/08/11/NtegrateNETJan1819th2010.aspx</link>
      <pubDate>Tue, 11 Aug 2009 22:42:56 GMT</pubDate>
      <description>&lt;b&gt;My New Endevour for the 2nd decade of the 21st Century&lt;/b&gt;
&lt;br&gt;
I'm excited to be taking on a new and exciting role in the coordination of &lt;a href="http://ntegrate.net"&gt;Ntegrate.NET&lt;/a&gt;. &lt;a href="http://ntegrate.net"&gt;Ntegrate.NET&lt;/a&gt; is
a Microsoft technology conference. It will be located at Hotel Sax and the House of
Blues in downtown Chicago on January 18th and 19th, 2010.&lt;br&gt;
&lt;br&gt;
&lt;b&gt;About Ntegrate.NET&lt;/b&gt;
&lt;br&gt;
This is an unofficial (whatever that really means) discussion of the event.&lt;br&gt;
&lt;a href="http://ntegrate.net"&gt;Ntegrate.NET&lt;/a&gt; is a community driven event that will
touch on the latest in Microsoft technology. It is designed to show off exciting real
world implementations and to teach others what Microsoft products are out there and
how they can help in a variety of corporate and small business scenarios.&amp;nbsp;&amp;nbsp;
Attendees will get to stay at the Hotel Sax and attend breakouts convering a variety
of topics.&amp;nbsp; Additionally, keynote presentations will be presented at the House
of Blues concert hall.&amp;nbsp; One such presentation will be from &lt;a href="http://www.hanselman.com/"&gt;Scott
Hanselman&lt;/a&gt;, who I'm extactic to have speak!&amp;nbsp; Lastly, the &lt;a href="http://ntegrate.net"&gt;Ntegrate.NET&lt;/a&gt; party
will be on the 2nd evening of the event at the House of Blues!&lt;br&gt;
&lt;br&gt;
&lt;b&gt;Partners&lt;/b&gt;
&lt;br&gt;
I'm more than greatful for all the support I've been getting so far.&amp;nbsp; This includes
Microsoft, my employer, &lt;a href="http://triton-tek.com"&gt;Triton-Tek&lt;/a&gt; , and &lt;a href="http://blog.jamieldesigns.com"&gt;Jamie
Lynn Designs&lt;/a&gt;. There are and probably will be several others who I will be more
than happy to give mention as things progress!&lt;br&gt;
&lt;br&gt;
Follow us on &lt;a href="http://twitter.com/NtegrateNET"&gt;Twitter &lt;/a&gt;and &lt;a href="http://www.facebook.com/group.php?gid=81596219721"&gt;Facebook&lt;/a&gt;!&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=63fbaf9f-3f22-49a3-9831-cdd36094940c" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,63fbaf9f-3f22-49a3-9831-cdd36094940c.aspx</comments>
      <category>Ntegrate.NET</category>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <b>The Problem</b>
        <br />
1) Opened two Windows Explorer windows.<br />
1a) First window navigate to my C:\Projects\MyProject\Bin\Release folder where "myassembly.dll"
lives.<br />
1b) Second window connected to remote machine via:  \\RemoteMachine\C$\Windows\Assembly<br /><br />
2) On second window, right click and select to uninstall assembly "myassembly.dll".<br />
3) On first window drag "myassembly.dll" to remote machine window seemingly placing
assembly in GAC.<br />
4) Test my code and see that latest changes aren't showing up.<br /><br />
This is the short version of what happened on my end, long version is that I repeated
steps 1 - 4 about 15 times throughout the day until I finally realized that I was
never reinstalling my assembly in the GAC.  In actuality I was never uninstalling
the assembly even though the 2nd Windows Explorer window pointing to the remote machine's
GAC made it look like I was.   
<br /><br />
To verify it wasn't working I RDCed to the remote machine and looked in the GAC after
seemingly uninstalling the assembly, and to my shock I had not been.<br /><br />
Anyway, lesson learned is that this needed to be done via RDC and not through a remotely
connected windows explorer!<br /><br /><p></p><img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7" /></body>
      <title>Problem removing assemblies from the GAC on remote machine</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7.aspx</guid>
      <link>http://blog.davearlin.com/2009/08/11/ProblemRemovingAssembliesFromTheGACOnRemoteMachine.aspx</link>
      <pubDate>Tue, 11 Aug 2009 22:22:32 GMT</pubDate>
      <description>&lt;b&gt;The Problem&lt;/b&gt;
&lt;br&gt;
1) Opened two Windows Explorer windows.&lt;br&gt;
1a) First window navigate to my C:\Projects\MyProject\Bin\Release folder where "myassembly.dll"
lives.&lt;br&gt;
1b) Second window connected to remote machine via:&amp;nbsp; \\RemoteMachine\C$\Windows\Assembly&lt;br&gt;
&lt;br&gt;
2) On second window, right click and select to uninstall assembly "myassembly.dll".&lt;br&gt;
3) On first window drag "myassembly.dll" to remote machine window seemingly placing
assembly in GAC.&lt;br&gt;
4) Test my code and see that latest changes aren't showing up.&lt;br&gt;
&lt;br&gt;
This is the short version of what happened on my end, long version is that I repeated
steps 1 - 4 about 15 times throughout the day until I finally realized that I was
never reinstalling my assembly in the GAC.&amp;nbsp; In actuality I was never uninstalling
the assembly even though the 2nd Windows Explorer window pointing to the remote machine's
GAC made it look like I was.&amp;nbsp;&amp;nbsp; 
&lt;br&gt;
&lt;br&gt;
To verify it wasn't working I RDCed to the remote machine and looked in the GAC after
seemingly uninstalling the assembly, and to my shock I had not been.&lt;br&gt;
&lt;br&gt;
Anyway, lesson learned is that this needed to be done via RDC and not through a remotely
connected windows explorer!&lt;br&gt;
&lt;br&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,1b542cd8-cc54-4d97-afeb-f1fe4bf52bc7.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=6b9df5d1-0b52-4c49-85d9-1196c5a36ee0</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,6b9df5d1-0b52-4c49-85d9-1196c5a36ee0.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,6b9df5d1-0b52-4c49-85d9-1196c5a36ee0.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6b9df5d1-0b52-4c49-85d9-1196c5a36ee0</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you don't know what SuperPreview is check it out here: <a href="http://expression.microsoft.com/en-us/dd565874.aspx">http://expression.microsoft.com/en-us/dd565874.aspx</a></p>
        <p>
I ran into an issue when trying to render a web page in either IE8 or IE 8-&gt;7 compatability
mode. I'm running the application on Vista x64. Basically, I get an error
that says "Insufficient memory to continue the execution of the program."  
</p>
        <p>
SuperPreview works just fine in IE6 mode which is the main reason I got it, but I
want to do the onion view of the two IE versions over one another.  Anyway, I
searched online for the issue and on the Expression Web forum, it just says to
e-mail <a href="mailto:superbug@microsoft.com">superbug@microsoft.com</a> to get assisstance. 
I did this, and within about 12 hrs, I got back another version of "Preview.HostedIE6Shim.dll"
which replaces the file of the same name in the root installation folder for SuperPreview.   
</p>
        <p>
I did this , and everything works now as expected. Very cool product, I can't
wait to see the next releases that support the non IE browsers!
</p>
        <img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=6b9df5d1-0b52-4c49-85d9-1196c5a36ee0" />
      </body>
      <title>SuperPreview "Insufficient memory to continue the execution of the program"</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,6b9df5d1-0b52-4c49-85d9-1196c5a36ee0.aspx</guid>
      <link>http://blog.davearlin.com/2009/04/06/SuperPreviewInsufficientMemoryToContinueTheExecutionOfTheProgram.aspx</link>
      <pubDate>Mon, 06 Apr 2009 18:52:35 GMT</pubDate>
      <description>&lt;p&gt;
If you don't know what SuperPreview is check it out here: &lt;a href="http://expression.microsoft.com/en-us/dd565874.aspx"&gt;http://expression.microsoft.com/en-us/dd565874.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I ran into an issue when trying to render a web page in either IE8 or IE 8-&amp;gt;7 compatability
mode.&amp;nbsp;I'm running the application&amp;nbsp;on Vista x64. Basically, I get an error
that says "Insufficient memory to continue the execution of the program."&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
SuperPreview works just fine in IE6 mode which is the main reason I got it, but I
want to do the onion view of the two IE versions over one another.&amp;nbsp; Anyway, I
searched online&amp;nbsp;for the issue and on the Expression Web forum, it just says to
e-mail &lt;a href="mailto:superbug@microsoft.com"&gt;superbug@microsoft.com&lt;/a&gt; to get assisstance.&amp;nbsp;
I did this, and within about 12 hrs, I got back another version of "Preview.HostedIE6Shim.dll"
which replaces the file of the same name in the root installation folder for SuperPreview.&amp;nbsp;&amp;nbsp; 
&lt;/p&gt;
&lt;p&gt;
I did this , and everything works now&amp;nbsp;as expected. Very cool product, I can't
wait to see the next releases that support the non IE browsers!
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=6b9df5d1-0b52-4c49-85d9-1196c5a36ee0" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,6b9df5d1-0b52-4c49-85d9-1196c5a36ee0.aspx</comments>
    </item>
    <item>
      <trackback:ping>http://blog.davearlin.com/Trackback.aspx?guid=990734e2-d0f6-4b0e-ac1e-070db6e477c6</trackback:ping>
      <pingback:server>http://blog.davearlin.com/pingback.aspx</pingback:server>
      <pingback:target>http://blog.davearlin.com/PermaLink,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</pingback:target>
      <dc:creator>Dave Arlin</dc:creator>
      <wfw:comment>http://blog.davearlin.com/CommentView,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</wfw:comment>
      <wfw:commentRss>http://blog.davearlin.com/SyndicationService.asmx/GetEntryCommentsRss?guid=990734e2-d0f6-4b0e-ac1e-070db6e477c6</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <h1>
          <font face="Verdana">
            <font size="2">Something New Everyday!</font>
            <br />
          </font>
        </h1>
        <p>
          <font face="Verdana"> Earlier today, I ran into a rather annoying issue that was painfully
hard to debug and narrow down the cause. While debugging some functionality that executed
on a postback, I had a breakpoint in my page .cs located at the start of our old friend,
Page_Load. So, it turns out my logic was working just fine on the postback call, but
once that Page_Load handler finished its run, low and behold, my breakpoint was hit
again?! 
<br /></font>
        </p>
        <h1>
          <font face="Verdana">
            <font size="2">Why Twice?</font>
            <br />
          </font>
        </h1>
        <p>
          <font face="Verdana"> This second run through was not being treated as a postback,
so a lot of my page initialization code was firing and undoing some changes that were
just done on my postback. After a painfully long time of commenting out C# code and
javascript and not being able to reproduce the problem, I finally narrowed it down
to the following line in my .aspx markup. </font>
        </p>
        <h4>
          <font face="Verdana">
            <font color="#0000ff">&lt;<font color="#000000">img src</font>="" <font color="#000000">width </font>=
"<font color="#000000">100</font>" <font color="#000000">height </font>= "<font color="#000000">100</font>"/&gt;</font>
          </font>
        </h4>
        <h1>
          <font size="2" face="Verdana">At Least It's an Easy Fix</font>
          <br />
        </h1>
        <p>
          <font face="Verdana"> Well it turns out that setting the src attribute to blank indicates
that you are self referencing the page that the img resides on. Thus, my Page_Load
event would fire a second time. If you're wondering why there is a blank src attribute,
the intention was to populate it via javascript at a later point. The potential fixes
are:</font>
        </p>
        <p>
          <font face="Verdana">1) Not specifying the src attribute at all. This however violates
w3c standards and will also give you annoying warning messages within Visual Studio<br /></font>
        </p>
        <p>
          <font face="Verdana">2) Just add a spacer image and set the src attribute to that. </font>
        </p>
        <img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=990734e2-d0f6-4b0e-ac1e-070db6e477c6" />
      </body>
      <title>The evil self referencing &amp;lt;img&amp;gt;</title>
      <guid isPermaLink="false">http://blog.davearlin.com/PermaLink,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</guid>
      <link>http://blog.davearlin.com/2009/02/13/TheEvilSelfReferencingLtimggt.aspx</link>
      <pubDate>Fri, 13 Feb 2009 06:42:16 GMT</pubDate>
      <description>&lt;h1&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;Something New Everyday!&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; Earlier today, I ran into a rather annoying issue that was painfully
hard to debug and narrow down the cause. While debugging some functionality that executed
on a postback, I had a breakpoint in my page .cs located at the start of our old friend,
Page_Load. So, it turns out my logic was working just fine on the postback call, but
once that Page_Load handler finished its run, low and behold, my breakpoint was hit
again?! 
&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;h1&gt;&lt;font face="Verdana"&gt;&lt;font size="2"&gt;Why Twice?&lt;/font&gt;
&lt;br&gt;
&lt;/font&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; This second run through was not being treated as a postback,
so a lot of my page initialization code was firing and undoing some changes that were
just done on my postback. After a painfully long time of commenting out C# code and
javascript and not being able to reproduce the problem, I finally narrowed it down
to the following line in my .aspx markup. &lt;/font&gt;
&lt;/p&gt;
&lt;h4&gt;
&lt;font face="Verdana"&gt;&lt;font color="#0000ff"&gt;&amp;lt;&lt;font color="#000000"&gt;img src&lt;/font&gt;="" &lt;font color="#000000"&gt;width &lt;/font&gt;=
"&lt;font color="#000000"&gt;100&lt;/font&gt;" &lt;font color="#000000"&gt;height &lt;/font&gt;= "&lt;font color="#000000"&gt;100&lt;/font&gt;"/&amp;gt;&lt;/font&gt;&lt;/font&gt;
&lt;/h4&gt;
&lt;h1&gt;&lt;font size="2" face="Verdana"&gt;At Least It's an Easy Fix&lt;/font&gt;
&lt;br&gt;
&lt;/h1&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt; Well it turns out that setting the src attribute to blank indicates
that you are self referencing the page that the img resides on. Thus, my Page_Load
event would fire a second time. If you're wondering why there is a blank src attribute,
the intention was to populate it via javascript at a later point. The potential fixes
are:&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt;1) Not specifying the src attribute at all. This however violates
w3c standards and will also give you annoying warning messages within Visual Studio&lt;br&gt;
&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Verdana"&gt;2) Just add a spacer image and set the src attribute to that. &lt;/font&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://blog.davearlin.com/aggbug.ashx?id=990734e2-d0f6-4b0e-ac1e-070db6e477c6" /&gt;</description>
      <comments>http://blog.davearlin.com/CommentView,guid,990734e2-d0f6-4b0e-ac1e-070db6e477c6.aspx</comments>
      <category>ASP.Net Page Life Cycle</category>
    </item>
  </channel>
</rss>