Helper Development - How's about Section Template?http://forums.asp.net/t/1193166.aspx/1?Helper+Development+How+s+about+Section+Template+Fri, 14 Dec 2007 04:45:19 -050011931662054521http://forums.asp.net/p/1193166/2054521.aspx/1?Helper+Development+How+s+about+Section+Template+Helper Development - How's about Section Template? <p>Hi,</p> <p>I've been around with MonoRail and for now looking forward to this &quot;ASP.NET MVC&quot; as my second choice for MVC framework under .NET. </p> <p>Familiarity with MonoRail makes me a little bit difficult to adapt to this ASP.NET MVC, especially when it comes to Helper development.<br> </p> <p>I'm trying to make a GridHelper that can be customized using the Section / Template like i did with MonoRail's GridComponent. Similar with templates in Repeater's WebForm. Any way to do this in ASP.NET MVC?<br> </p> <p>Any suggest would be appreciated.</p> <p>Thanks&nbsp;</p> 2007-12-12T05:56:44-05:002055236http://forums.asp.net/p/1193166/2055236.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <p>You should be able to create a standard ASP.NET Server Control to do this. Over the last few days I've converted most of my MonoRail View Components into ASP.NET Server Controls and this seems to work fine (so long as the control doesn't require postback). You can create a customisable section/template by using properties of type ITemplate. <br> </p> 2007-12-12T12:39:52-05:002056000http://forums.asp.net/p/1193166/2056000.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <p>I'm not familiar with MonoRails section/template bits - can you give me some details? Also- have you tried using a UserControl (and RenderUserControl) to do this?</p> 2007-12-12T18:18:39-05:002056673http://forums.asp.net/p/1193166/2056673.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>JeremyS</h4> <p></p> <p>You should be able to create a standard ASP.NET Server Control to do this.<br> </p> <p></p> </blockquote> <p></p> <p>I also read the article from ScottGu (Part 3 : Passing ViewData From Controllers to View) that explain this. Maybe i just don't like the <b>Page_Load</b> event when doing this, because in MonoRail there'll be no such things like Page Events.<br> <br> I always try to avoid using Page Events to get clean View, but you have gave me an idea about how to do that in ASP.NET MVC.</p> <p>Thanks JeremyS.</p> <p>*Why i still get this feeling that, still, MonoRail has cleaner View than ASP.NET MVC* [Angel]<br> </p> 2007-12-13T01:09:47-05:002057220http://forums.asp.net/p/1193166/2057220.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <blockquote><span class="icon-blockquote"></span> <h4>airl4ngg4</h4> <br> *Why i still get this feeling that, still, MonoRail has cleaner View than ASP.NET MVC*<br> </blockquote> <br> <br> I know what you mean. Personally, I prefer the dynamic nature of Brail and NVelocity when working in views. Having to deal with C# and its static-ness in the view seems a little...cumbersome. Perhaps there will be an IronRuby view engine in time. On the plus side, its nice to have intellisense again ;)<br> <br> I'm also not fond of using page events for the views. In fact, I've deleted the codebehind for all of my .aspx files.<br> <br> For databinding my server controls I'm using the CodeExpressionBuilder found at <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx"> http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx</a>. Instead of having to set the DataSource from codebehind I can do something like this:&nbsp;<pre class="prettyprint">&lt;cw:MyCustomControl runat=&quot;server&quot; id=&quot;control&quot; DataSource='&lt;%$ code: ViewData[&quot;someCollection&quot;] %&gt;' /&gt;</pre><p><blockquote><span class="icon-blockquote"></span><h4>robconery</h4>I'm not familiar with MonoRails section/template bits - can you give me some details?</blockquote><br><br>In MonoRail, a ViewComponent is very similar to a server control. It allows you to re-use portions of your UI across views and you can set various properties on it. One of the most useful things about viewcomponents is how you can override sections of a viewcomponent to support custom rendering. For example, a repeater component might look like this: &nbsp;</p><pre class="prettyprint"><span class="dir">&lt;%<br></span>component Repeater, { @id: "someId", @datasource: someCollecton }:<br> section item:<br> output "this is an item: &#36;{item}"<br> end<br> section alternatingItem:<br> output "this is the alternating item: &#36;{item}"<br> end<br>end<br><span class="dir">%&gt;</span></pre>&nbsp;<br> <br> 2007-12-13T07:42:48-05:002059197http://forums.asp.net/p/1193166/2059197.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>JeremyS</h4> <p></p> <p>For databinding my server controls I'm using the CodeExpressionBuilder found at <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx"> http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx</a>. Instead of having to set the DataSource from codebehind I can do something like this:&nbsp;</p> <pre class="prettyprint">&lt;cw:MyCustomControl runat=&quot;server&quot; id=&quot;control&quot; DataSource='&lt;%$ code: ViewData[&quot;someCollection&quot;] %&gt;' /&gt;</pre> <p></p> </blockquote> &nbsp; <p></p> <p>Awesome! I'll try that too!<br> </p> <p>It would be great if this features also included in the next release of ASP.NET MVC.<br> </p> *Will you, Scott?* [Angel]<br> 2007-12-14T01:21:53-05:002059432http://forums.asp.net/p/1193166/2059432.aspx/1?Re+Helper+Development+How+s+about+Section+Template+Re: Helper Development - How's about Section Template? <p></p> <blockquote><span class="icon-blockquote"></span> <h4>JeremyS</h4> <p></p> <p>For databinding my server controls I'm using the CodeExpressionBuilder found at <a href="http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx"> <font color="#034efa">http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx</font></a>. Instead of having to set the DataSource from codebehind I can do something like this:&nbsp;</p> <pre class="prettyprint">&lt;cw:MyCustomControl runat=&quot;server&quot; id=&quot;control&quot; DataSource='&lt;%$ code: ViewData[&quot;someCollection&quot;] %&gt;' /&gt;</pre><pre class="prettyprint">&nbsp;</blockquote></pre><pre class="prettyprint">I'm glad I came by here, I had been looking for the syntax for accessing variables in servercontrol properties. </pre><pre class="prettyprint">&nbsp;Thanks</pre></blockquote> 2007-12-14T04:45:19-05:00