Helpers

The helpers are used to perform common tasks in either HTML or JavaScript.

The JS implementation is abstract which means that it can support multiple javascript frameworks. Support have currently only been made for PrototypeJS.

WebHelper

Webhelper let's you do common actions that doesnt fit into JSHelper or FormHelper. It can be to create links that are using Ajax or to Generate a UL-tag list.

FormHelper

Formhelper can for instance be used to create forms that work both as regular forms or ajax.
<%= FormHelper.Start("formName", "/user/create/", Request.IsAjax); %>
// form inputs
<%= FormHelper.End() %>

That will create a ajax form if the request is made by ajax, or a regular form if not.

Select helper method
 // Class that is going to be used in a SELECT-tag.
 public class User
 {
     private readonly string _realName;
     private readonly int _id;
     public User(int id, string realName)
     {
         _id = id;
         _realName = realName;
     }
     public string RealName
     {
         get { return _realName; }
     }
 
     public int Id
     {
         get { return _id; }
     }
 }
 
 // Generate a SELECT-tag with all users.
 public void GenerateSelectList()
 {
     List<User> items = new List<User>();
     items.Add(new User(1, "adam"));
     items.Add(new User(2, "bertial"));
     items.Add(new User(3, "david"));
     string htmlSelect = FormHelper.Select("users", items, UserOptions, 1, true);
 }
 
 // delegate returning id and title
 public static void UserOptions(object o, out object id, out object title)
 {
     User user = (User)o;
     id = user.Id;
     value = user.RealName;
 }

JSHelper

Lets you perform common javascript tags (without having to use javascript framework dependent code)

Last edited Jun 23, 2008 at 7:08 AM by jgauffin, version 3

Comments

No comments yet.