







Delegate used by Select(String, IEnumerable, GetIdTitle, Object, Boolean) to populate select options.
Namespace:
HttpServer.Helpers
Assembly:
HttpServer (in HttpServer.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
C# |
---|
public delegate void GetIdTitle( Object obj, out Object id, out string title ) |
Visual Basic (Declaration) |
---|
Public Delegate Sub GetIdTitle ( _ obj As Object, _ <OutAttribute> ByRef id As Object, _ <OutAttribute> ByRef title As String _ ) |
Visual C++ |
---|
public delegate void GetIdTitle( Object^ obj, [OutAttribute] Object^% id, [OutAttribute] String^% title ) |
Parameters
- obj
- Type: System..::.Object
current object (for instance a User).
- id
- Type:
System..::.Object
%
Text that should be displayed in the value part of a <optiongt;-tag.
- title
- Type:
System..::.String
%
Text shown in the select list.
Examples
// 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; }
}
}
// Using an inline delegate to generate the select list
public void UserInlineDelegate()
{
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 = Select("users", "users", items, delegate(object o, out object id, out object value)
{
User user = (User)o;
id = user.Id;
value = user.RealName;
}, 2, true);
}
// Using an method as delegate to generate the select list.
public void UseExternalDelegate()
{
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 = Select("users", "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;
} ///