car={Wheels=4,Year=2007,Model='Cheap'}
And you want to bind those values to a instance of yours Car class, which looks like this:
public class Car
{
private int wheels, year;
private string model;
public int Wheels
{
get { return wheels; }
set { wheels = value; }
}
public int Year
{
get { return year; }
set { year = value; }
}
public string Model
{
get { return model; }
set { model = value; }
}
}
public void MyAction([JSONBinder("car")] Car car)
<monorail>
<extensions>
<extension type="Castle.MonoRail.Framework.Extensions.ExceptionChaining.ExceptionChainingExtension, Castle.MonoRail.Framework" />
</extensions>
<exception>
<exceptionHandler type="Type name that implements IExceptionHandler" />
<exceptionHandler type="Type name that implements IExceptionHandler" />
</exception>
</monorail>
();
exProcessor.ProcessException(ex);
RenderView("CouldNotBuyMercedes");
}
}
]]>
<monoRail customSession="Type name that implements ICustomSessionFactory">
<extensions>
<extension type="Castle.MonoRail.Framework.Extensions.Session.CustomSessionExtension, Castle.MonoRail.Framework" />
</extensions>
</monoRail>
RenderScriptBlockToSource("/my/url/to/my/scripts");
]]>
As you see the file extension will be inferred
RenderScriptBlockToSource("/my/url/to/my/scripts", "locale=pt-br");
]]>
As you see the file extension will be inferred
key1="value1" key2
IDictionary dict = new Hashtable();
dict.Add("id", 5);
dict.Add("selectedItem", new int[] { 2, 4, 99 });
string querystring = BuildQueryString(dict);
// should result in: "id=5&selectedItem=2&selectedItem=4&selectedItem=99"
<script type=\"text/javascript\">
scriptContents
</script>
<a href="javascript:void(0);" onclick="functionCodeOrName; return false">innerContent</a>
<a href="javascript:void(0);" onclick="confirm('question') { functionCodeOrName}; return false">innerContent</a>
helper.CreateDict( "style=display: none;", "selected" )
DictHelper.Create( "style=display: none;", "selected" )
VisualEffect('ToggleSlide', 'elementid')
VisualEffect('ToggleBlind', 'elementid')
VisualEffect('ToggleAppear', 'elementid')
VisualEffect('Highlight', 'elementid')
VisualEffect('Fade', 'elementid')
VisualEffect('Shake', 'elementid')
VisualEffect('DropOut', 'elementid')
VisualEffect('ToggleSlide', 'elementid')
VisualEffect('ToggleBlind', 'elementid')
VisualEffect('ToggleAppear', 'elementid')
VisualEffect('Highlight', 'elementid')
VisualEffect('Fade', 'elementid')
VisualEffect('Shake', 'elementid')
VisualEffect('DropOut', 'elementid')
VisualEffectDropOut('elementid', {position:'end', scope='test', limit=2})
<div id="x"><div>contents</div></div>
Because of a bug in Internet Explorer 6 (overflow not correctly hidden),
an additional wrapper div is needed if you want to use these effects on
absolutely positionend elements (wrapper is the absolutely positioned element,
x has position:relative; set; ):
<div id="wrapper">
<div id="x"><div>contents</div></div>
</div>
Works only on block elements.
<div id="x"><div>contents</div></div>
Because of a bug in Internet Explorer 6 (overflow not correctly hidden),
an additional wrapper div is needed if you want to use these effects on
absolutely positionend elements (wrapper is the absolutely positioned element,
x has position:relative; set; ):
<div id="wrapper">
<div id="x"><div>contents</div></div>
</div>
Works only on block elements.
Watch me fade
ADVANCED USE: Change the default fade from color:Watch me fade from Blue (#0066FF)
SEE MORE HERE: http://www.axentric.com/posts/default/7
public void MyAction()
{
PropertyBag["name"] = "John Doe";
}
$Form.TextField('name') // Renders an input text with value "John Doe"
public void MyAction()
{
PropertyBag["user"] = new User("John Doe");
}
$Form.TextField('user.name') // Renders an input text with value "John Doe"
$Form.FormTag("%{action='Save',id='productform'}")
Outputs:
<form method='post' action='/[appdir]/[controller]/Save.[extension]' id='productform'>
$Form.FormTag('mytarget.castle', "%{id='productform'}")
Outputs:
<form method='post' action='mytarget.castle' id='productform'>
$Form.TextField('username')
Outputs:
<input type='text' name='username' id='username' value='John Doe' />
$Form.TextField('user.name')
Outputs:
<input type='text' name='user.name' id='user_name' value='John Doe' />
FormHelper.FilteredTextField("product.price", {forbid='46'})
In this case the key code 46 (period) will not be accepted on the field.
FormHelper.NumberField("product.price", {exceptions='13,10,11'})
In this case the key codes 13, 10 and 11 will be accepted on the field.
FormHelper.NumberField("product.price", {forbid='46'})
In this case the key code 46 (period) will not be accepted on the field.
FormHelper.NumberField("product.price", {exceptions='13,10,11'})
In this case the key codes 13, 10 and 11 will be accepted on the field.
FormHelper.NumberField("product.price", {forbid='46'})
In this case the key code 46 (period) will not be accepted on the field.
public void Index()
{
// data source
PropertyBag["primenumbers"] = new int[] { 2, 3, 5, 7, 11, 13, 17, 19, 23 };
// initial selection
PropertyBag["selectedPrimes"] = new int[] { 11, 19 };
}
And the respective view code
#set($items = $FormHelper.CreateCheckboxList("selectedPrimes", $primenumbers))
#foreach($elem in $items)
$items.Item() $elem
#end
That will generates the following html:
<input type="checkbox" id="selectedPrimes_0_" name="selectedPrimes[0]" value="2" /> 2
<input type="checkbox" id="selectedPrimes_1_" name="selectedPrimes[1]" value="3" /> 3
<input type="checkbox" id="selectedPrimes_2_" name="selectedPrimes[2]" value="5" /> 5
<input type="checkbox" id="selectedPrimes_3_" name="selectedPrimes[3]" value="7" /> 7
<input type="checkbox" id="selectedPrimes_4_" name="selectedPrimes[4]" value="11" checked="checked" /> 11
<input type="checkbox" id="selectedPrimes_5_" name="selectedPrimes[5]" value="13" /> 13
<input type="checkbox" id="selectedPrimes_6_" name="selectedPrimes[6]" value="17" /> 17
<input type="checkbox" id="selectedPrimes_7_" name="selectedPrimes[7]" value="19" checked="checked" /> 19
<input type="checkbox" id="selectedPrimes_8_" name="selectedPrimes[8]" value="23" /> 23
#set($items = $FormHelper.CreateCheckboxList("selectedPrimes", $primenumbers))
#foreach($elem in $items)
$items.Item("myId${velocityCount}") $Form.LabelFor("myId${velocityCount}", $elem.ToString())
#end
public void Index()
{
Category[] categories = new Category[] { new Category(1, "Music"), new Category(2, "Humor"), new Category(3, "Politics") };
PropertyBag["categories"] = categories; // datasource
Blog blog = new Blog();
blog.Categories = new Category[] { new Category(2, "Humor") }; // initial selection
PropertyBag["blog"] = blog;
}
And the respective view code
#set($items = $Form.CreateCheckboxList("blog.categories", $categories, "%{value='Id'}"))
#foreach($elem in $items)
$items.Item() $elem
#end
That will generates the following html:
<input type="checkbox" id="blog_categories_0_" name="blog.categories[0].Id" value="1" /> Music
<input type="checkbox" id="blog_categories_1_" name="blog.categories[1].Id" value="2" checked="checked" /> Humor
<input type="checkbox" id="blog_categories_2_" name="blog.categories[2].Id" value="3" /> Politics
$Form.CheckboxField('user.disabled')
That is going to output:
<input type="checkbox" id="user_disabled" name="user.disabled" value="true" />
<input type="hidden" id="user_disabledH" name="user.disabled" value="false" />
public void Index()
{
PropertyBag["mode"] = FileMode.Truncate;
}
And the following view code:
$Form.RadioField("mode", "Append") FileMode.Append
$Form.RadioField("mode", "Create") FileMode.Create
$Form.RadioField("mode", "CreateNew") FileMode.CreateNew
$Form.RadioField("mode", "Open") FileMode.Open
$Form.RadioField("mode", "OpenOrCreate", "%{id='customhtmlid'}") FileMode.OpenOrCreate
$Form.RadioField("mode", "Truncate") FileMode.Truncate
That is going to output:
<input type="radio" id="mode" name="mode" value="Append" /> FileMode.Append
<input type="radio" id="mode" name="mode" value="Create" /> FileMode.Create
<input type="radio" id="mode" name="mode" value="CreateNew" /> FileMode.CreateNew
<input type="radio" id="mode" name="mode" value="Open" /> FileMode.Open
<input type="radio" id="customhtmlid" name="mode" value="OpenOrCreate" /> FileMode.OpenOrCreate
<input type="radio" id="mode" name="mode" value="Truncate" checked="checked" /> FileMode.Truncate
<fieldset><legend>legendArg</legend>
<fieldset><legend>legendArg</legend>
$HtmlHelper.FieldSet( "legendArg" )
...
$HtmlHelper.EndFieldSet()
</fieldset>
</fieldset>
$HtmlHelper.FieldSet( "legendArg" )
...
$HtmlHelper.EndFieldSet()
<form method="post" action="actionArg">
<form method="post" action="actionArg">
$HtmlHelper.Form( "actionArg" )
...
$HtmlHelper.EndForm()
<form method="methodArg" action="actionArg" id="idArg">
<form method="methodArg" action="actionArg" id="idArg">
$HtmlHelper.Form( "actionArg", "idArg", "methodArg" )
...
$HtmlHelper.EndForm()
<form method="methodArg" action="actionArg" id="idArg" onsubmit="onSubmitArg">
<form method="methodArg" action="actionArg" id="idArg" onsubmit="onSubmitArg">
$HtmlHelper.Form( "actionArg", "idArg", "methodArg", "submitHandler()" )
...
$HtmlHelper.EndForm()
<form action="actionArg">
</form>
</form>
$HtmlHelper.Form( "actionArg", "idArg", "methodArg", "submitHandler()" )
...
$HtmlHelper.EndForm()
<a href="/sometarget.html">linkText</a>
<a href="something.html">something</a>
$HtmlHelper.Link( "mypage.html", "This is a link to my page" )
<a href="/sometarget.html">linkText</a>
<a href="something.html" class="mylinkclass">something</a>
$HtmlHelper.Link( "mypage.html", "This is a link to my page", $DictHelper.CreateDict("class=mylinkclass") )
<a href="/website/currentController/actionArg.rails">nameArg</a>
<a href="/websiter/currentController/actionArg.rails">nameArg</a>
$HtmlHelper.LinkTo( "linkName", "requiredAction" )
<a href="/website/currentController/actionArg.rails">nameArg</a>
<a href="/websiter/home/index.rails">nameArg</a>
$HtmlHelper.LinkTo( "linkName", DictHelper.CreateDict("controller=home","action=index") )
<a href="/website/controllerArg/actionArg.rails">nameArg</a>
<a href="/website/controllerArg/actionArg.rails">nameArg</a>
$HtmlHelper.LinkTo( "linkName", {@action:} )
<a href="/website/controllerArg/actionArg.rails?id=objectId">nameArg</a>
<a href="/website/controllerArg/actionArg.rails?id=object">nameArg</a>
$HtmlHelper.LinkTo( "linkName", "someController", "requiredAction", objectToRefByID )
<a href="/website/controllerArg/actionArg.rails">nameArg</a>
<a href="/website/controllerArg/actionArg.rails">nameArg</a>
$HtmlHelper.LinkToAttributed( "linkName", "someController", "requiredAction", $DictHelper.CreateDict("class=something") )
<a href="/website/controllerArg/actionArg.rails?id=x">nameArg</a>
<a href="/website/controllerArg/actionArg.rails">nameArg</a>
$HtmlHelper.LinkToAttributed( "linkName", "someController", "requiredAction", $DictHelper.CreateDict("class=something") )