I've been around with MonoRail and for now looking forward to this "ASP.NET MVC" as my second choice for MVC framework under .NET.
Familiarity with MonoRail makes me a little bit difficult to adapt to this ASP.NET MVC, especially when it comes to Helper development.
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?
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.
Marked as answer by airl4ngg4 on Dec 13, 2007 01:11 AM
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?
You should be able to create a standard ASP.NET Server Control to do this.
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
Page_Load event when doing this, because in MonoRail there'll be no such things like Page Events.
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.
Thanks JeremyS.
*Why i still get this feeling that, still, MonoRail has cleaner View than ASP.NET MVC* [Angel]
*Why i still get this feeling that, still, MonoRail has cleaner View than ASP.NET MVC*
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 ;)
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.
I'm not familiar with MonoRails section/template bits - can you give me some details?
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:
<% component Repeater, { @id: "someId", @datasource: someCollecton }: section item: output "this is an item: ${item}" end section alternatingItem: output "this is the alternating item: ${item}" end end %>
airl4ngg4
Member
13 Points
4 Posts
Helper Development - How's about Section Template?
Dec 12, 2007 05:56 AM|LINK
Hi,
I've been around with MonoRail and for now looking forward to this "ASP.NET MVC" as my second choice for MVC framework under .NET.
Familiarity with MonoRail makes me a little bit difficult to adapt to this ASP.NET MVC, especially when it comes to Helper development.
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?
Any suggest would be appreciated.
Thanks
JeremyS
Member
506 Points
99 Posts
Re: Helper Development - How's about Section Template?
Dec 12, 2007 12:39 PM|LINK
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.
robconery
Participant
852 Points
195 Posts
Re: Helper Development - How's about Section Template?
Dec 12, 2007 06:18 PM|LINK
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?
airl4ngg4
Member
13 Points
4 Posts
Re: Helper Development - How's about Section Template?
Dec 13, 2007 01:09 AM|LINK
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 Page_Load event when doing this, because in MonoRail there'll be no such things like Page Events.
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.
Thanks JeremyS.
*Why i still get this feeling that, still, MonoRail has cleaner View than ASP.NET MVC* [Angel]
JeremyS
Member
506 Points
99 Posts
Re: Helper Development - How's about Section Template?
Dec 13, 2007 07:42 AM|LINK
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 ;)
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.
For databinding my server controls I'm using the CodeExpressionBuilder found at http://weblogs.asp.net/infinitiesloop/archive/2006/08/09/The-CodeExpressionBuilder.aspx. Instead of having to set the DataSource from codebehind I can do something like this:
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:
airl4ngg4
Member
13 Points
4 Posts
Re: Helper Development - How's about Section Template?
Dec 14, 2007 01:21 AM|LINK
Awesome! I'll try that too!
It would be great if this features also included in the next release of ASP.NET MVC.
*Will you, Scott?* [Angel]slynch
Member
349 Points
71 Posts
Re: Helper Development - How's about Section Template?
Dec 14, 2007 04:45 AM|LINK