Databases Reference
In-Depth Information
Extending DynamicControl (Again)
The UnleashedControl class introduced in the beginning of this chapter takes care of
initializing its Mode property based on the mode of the entity template that hosts it. This
control can provide several additional properties and methods to make manipulating field
templates easier. Listing 10.21 shows the final version of this class. With the exception of
the first half of the OnInit method, the rest of its code is new.
LISTING 10.21 Final Version of the UnleashedControl
using System;
using System.ComponentModel;
using System.Web.DynamicData;
using System.Web.UI.WebControls;
namespace Unleashed.DynamicData
{
public class UnleashedControl : DynamicControl
{
private static readonly object FieldValueChangedEvent = new object();
public new UnleashedFieldTemplate FieldTemplate
{
get { return (UnleashedFieldTemplate)base.FieldTemplate; }
}
[Browsable(false)]
public object FieldValue
{
get { return this.FieldTemplate.FieldValue; }
set { this.FieldTemplate.FieldValue = value; }
}
public event EventHandler FieldValueChanged
{
add
{
this.Events.AddHandler(FieldValueChangedEvent, value);
if (this.FieldTemplate != null)
this.FieldTemplate.FieldValueChanged += value;
}
remove
{
this.Events.RemoveHandler(FieldValueChangedEvent, value);
if (this.FieldTemplate != null)
this.FieldTemplate.FieldValueChanged -= value;
}
 
Search WWH ::




Custom Search