﻿<?xml version="1.0" encoding="utf-8"?><rss version="2.0"><channel><title>Ayende @ Rahien</title><link>http://ayende.com</link><description>Ayende @ Rahien</description><copyright>Copyright (C) Ayende Rahien  2004 - 2021 (c) 2026</copyright><ttl>60</ttl><item><title>Ayende Rahien commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>@Jeff,
  
Yes, but then I need to manage the state transfer in the code behind.
  
It also means that I need to create user controls for non reusable stuff.
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment6</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment6</guid><pubDate>Thu, 07 Jun 2007 04:41:58 GMT</pubDate></item><item><title>Jeff Perrin commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>Ayende,
  
  
Put the complex html for each branch in a usercontrol.
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment5</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment5</guid><pubDate>Thu, 07 Jun 2007 02:49:30 GMT</pubDate></item><item><title>Ayende Rahien commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>joe,
  
put ~ 50 lines of complex HTML on each branch, and you will get a mess.
  
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment4</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment4</guid><pubDate>Wed, 06 Jun 2007 23:24:07 GMT</pubDate></item><item><title>joe commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>A lot of people forget that you can still write old school asp style in ASP.NET. What I choose most of the time over using controls is something more like this:
  
  
&lt;% foreach (Policy policy in Policies) { %&gt;
  
   &lt;% if (policy.Expired ) { %&gt;
  
      Policy expired
  
   &lt;% } else { %&gt;
  
      Policy valid until &lt;%= policy.ExpiryDate %&gt;
  
  &lt;% } %&gt;
  
&lt;% } %&gt;
  
  
oh, and if you insist on using databinding can't you just write this:
  
&lt;%# ((Policy)Container.DataItem).Expired ? "Policy expired" : "Policy valid until " + ((Policy)Container.DataItem).ExpiryDate.ToString() %&gt;
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment3</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment3</guid><pubDate>Wed, 06 Jun 2007 23:08:05 GMT</pubDate></item><item><title>Ayende Rahien commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>@Aaron,
  
Interesting, this is the first I see this approach.
  
Now I won't have to implement the SwitchRenderer :-)
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment2</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment2</guid><pubDate>Wed, 06 Jun 2007 21:30:29 GMT</pubDate></item><item><title>Aaron Jensen commented on rails:ConditionalRender - still trying to get WebForms to work right</title><description>I'm sure you know this.. but MultiView will do just this out of the box (albeit a bit uglier and less expressive) _I think_... it's been a while since I've used it, but try something like this:
  
&lt;asp:MultiView runat="server" ActiveViewIndex="&lt;%# Condition ? 0 : 1%&gt;"&gt;
  
  &lt;asp:View runat="server"&gt;
  
    True case
  
  &lt;/asp:View&gt;
  
  &lt;asp:View runat="server"&gt;
  
    False case
  
  &lt;/asp:View&gt;
  
&lt;/asp:MultiView&gt;
  
  
We also used asp:Views w/ visible="&lt;%# Condition %&gt;" for things that didn't need an else.
</description><link>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment1</link><guid>http://ayende.com/2510/rails-conditionalrender-still-trying-to-get-webforms-to-work-right#comment1</guid><pubDate>Wed, 06 Jun 2007 21:24:41 GMT</pubDate></item></channel></rss>