this page aim to recense every feature that can be used in AspView templates, it's a work in progress.
the page directive
it's purpose is to define the base class of the view declaring it. It's also there to enable intellisense.
 |
- unique
- non mandatory (will default to the one defined in the sample syntax)
|
sample syntax
<%page language="c#" inherits="Castle.MonoRail.Views.AspView.ViewAtDesignTime"%>
note that the inherits directive's attribute has special behavior, please refer to this blog entry http://www.kenegozi.com/Blog/2007/12/13/new-stuff-in-aspview.aspx
for now
It's possible to use genericized base view page such as
<%page language="c#" inherits="Castle.MonoRail.Views.AspView.ViewAtDesignTime<IStronglyTypedPropertiesWrapper>"%>
then StronglyTypedPropertiesWrapper instance is accessible with the view property such as:
 | you don't have to provide an instance of IStronglyTypedPropertiesWrapper (or ever implement one), it is automagically created using [DictionaryAdapter] which will wrap the PropertyBag and map matching properties which you declared on your StronglyTypedPropertiesWrapper type |
the import directive
it's purpose is to import namespace, avoiding the use of fully qualified type names. It's also there to enable intellisense.
 |
- non mandatory
- multiple can be defined
|
sample syntax
<%import namespace="Namespace.To.Import"%>
view properties declaration
 |
- unique
- non mandatory (you can use the parametized Generic 'view' Property)
- must follow page or import directive
|
sample syntax
<aspView:properties><%
PropertyType propertyName;
%></aspView:properties>
or
<script runat="server" type="aspview/properties">
PropertyType propertyName;
</script>
important notes
 |
- when used, property names are mapped to the elements defined in the PropertyBag, it's actually done in a case insensitive manner
- you can initialize default value for defined properties (if not set in the PropertyBag) with the c# initialization
- you can't use c# 3 'var' declaration when initializing the property
- one property per line
|
dynamic value output
sample syntax
raw output
html encoded output
<%#propertyName%>
or
<%=(propertyName)%>
or
${propertyName}
view components
 |
- are used in the body of the template
|
sample syntax
simpliest
<component:viewcomponentname>
</component:viewcomponentname>
 |
- view component name is case insensitive
- you can't use self closing tag
- it don't have to span multiple lines
|
passing string literal to view component's properties
simply use the natural html/xml way to do it
<component:viewcomponentname propertyname="literal property value">
</component:viewcomponentname>
 |
- property names are case insensitive
|
passing values to view component's properties
<component:viewcomponentname propertyname="<%=something.Wise">">
</component:viewcomponentname>
using view component body
<component:viewcomponentname>
body contents
</component:viewcomponentname>
using view component sections
<component:viewcomponentname propertyname="<%=something.Wise">">
<section:sectionname>section contents</section:sectionname>
</component:viewcomponentname>
 |
- section name is case sensitive
|
embeded script
used to embed short helper methods that are view specific
sample syntax
<script runat="server">
string DoubleIt(string toBeDoubled){ return String.Format("{0}{0}",toBeDoubled); }
</script>
<%=DoubleIt("me")%>
 |
- don't embed complex logic in such scripts (logic in view is evil, you can't unit test it)
- it may work with view extension methods (not tested yet)
|