Databases Reference
In-Depth Information
Compared to the original version of this field template shown in Listing 10.11, the only
difference in the final markup of the
Region
field template is the addition of the
AutoPostBack
and
OnTextChanged
attributes to the
TextBox
control. These changes actu-
ally implement the
UnleashedFieldTemplate
pattern and are not directly related to
moving the logic for determining
Country
field value out of this template.
LISTING 10.20
Final Version of the Region_Edit Field Template (Code-Behind)
using System;
using System.Collections.Specialized;
using System.Web.UI;
namespace WebApplication.DynamicData.FieldTemplates
{
public partial class RegionEditField : UnleashedFieldTemplate
{
public string Country
{
get { return this.autoCompleteExtender.ContextKey; }
set { this.autoCompleteExtender.ContextKey = value; }
}
public override Control DataControl
{
get { return this.textBox; }
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.textBox.ToolTip = this.Column.Description;
this.SetUpValidator(this.requiredFieldValidator);
this.SetUpValidator(this.dynamicValidator);
}
protected override void ExtractValues(IOrderedDictionary dictionary)
{
dictionary[this.Column.Name] = this.ConvertEditedValue(this.textBox.Text);
}
protected void TextBox_TextChanged(object sender, EventArgs e)
{
this.OnFieldValueChanged(e);
}
}
}