Originally Posted by
Daniil
Hi,
I would inherit the control from, for example, Ext.Net.CompositeField or Ext.Net.Container, create two TimeFields controls within the control's constructor and place these TimeField's into the control's Items collection.
How would you implement it in the markup?
Hi Daniil.
Inherting from customfield fixed my issue. Thank you. I am trying to validate the entries. My custom control is a number range control havng from and to text fields. I need to validate the upper and lower values. below is the code i am using now. This is function is executed any time.Please let me know if i am missing something.
using System;
using System.Collections.Generic;
using System.Linq;
using Ext.Net;
namespace NexiantSuite.NxtWebControls.Controls
{
public class CurrencyRange : CompositeField
{
NxtNumberField FromCurrency = new NxtNumberField();
NxtNumberField ToCurrency = new NxtNumberField();
public CurrencyRange()
{
FromCurrency.ID = "FromCurrency";
FromCurrency.FieldLabel = "From";
FromCurrency.Width = 100;
FromCurrency.AllowBlank = false;
FromCurrency.AllowDecimals = false;
FromCurrency.IndicatorIcon = Icon.BulletRed;
FromCurrency.IsRemoteValidation = true;
FromCurrency.RemoteValidation.Validation += new RemoteValidationDirectEvent.RemoteValidationEventHandler(FromCurrencyValidateEvent_Validation);
ConfigItem FromCurrencyConfig = new ConfigItem();
FromCurrencyConfig.Name = "ToCurrencyConfig";
FromCurrencyConfig.Value = "#{ToCurrency}";
FromCurrencyConfig.Mode = ParameterMode.Value;
FromCurrency.CustomConfig.Add(FromCurrencyConfig);
ToCurrency.ID = "ToCurrency";
ToCurrency.FieldLabel = "To";
ToCurrency.LabelAlign = Ext.Net.LabelAlign.Top;
ToCurrency.Width = 100;
ToCurrency.AllowBlank = false;
ToCurrency.AllowDecimals = false;
ToCurrency.IndicatorIcon = Icon.BulletRed;
ToCurrency.IsRemoteValidation = true;
ToCurrency.RemoteValidation.Validation += new RemoteValidationDirectEvent.RemoteValidationEventHandler(ToCurrencyValidateEvent_Validation);
ConfigItem ToCurrencyConfig = new ConfigItem();
ToCurrencyConfig.Name = "FromCurrencyConfig";
ToCurrencyConfig.Value = "#{FromCurrency}";
ToCurrencyConfig.Mode = ParameterMode.Value;
ToCurrency.CustomConfig.Add(ToCurrencyConfig);
this.FieldLabel = "From";
this.Items.Add(FromCurrency);
this.Items.Add(ToCurrency);
}
void FromCurrencyValidateEvent_Validation(object sender, RemoteValidationEventArgs e)
{
double FromCurrency = double.Parse(e.Value.ToString());
if (!string.IsNullOrEmpty(ToCurrency.Value.ToString()))
{
double toCurrency = double.Parse(ToCurrency.Value.ToString());
if (toCurrency > FromCurrency)
{
e.Success = true;
}
else
{
e.Success = false;
e.ErrorMessage = "";
}
}
}
void ToCurrencyValidateEvent_Validation(object sender, RemoteValidationEventArgs e)
{
double ToCurrency = double.Parse(e.Value.ToString());
if (!string.IsNullOrEmpty(FromCurrency.Value.ToString()))
{
double fromCurrency = double.Parse(FromCurrency.Value.ToString());
if (ToCurrency > fromCurrency)
{
e.Success = true;
}
else
{
e.Success = false;
e.ErrorMessage = "";
}
}
}
}
}
Thanks
Anulekha