Visual Basic
C#
C# | Copy Code |
---|---|
using Netcad.Netigma.Web.MultiLang; using System; using System.Data; using Netcad.Data.Filtering; using Netcad.Web.UI.StringParser; using Netcad.Xml; using System.ComponentModel; using System.Collections.Generic; using System.Web.UI.WebControls; using Netcad.Netigma.Web.Controls.BasicControls; using System.Web; using System.Web.UI; using Netcad.Web.Controls; namespace Netcad.Netigma.Web { [PropertyApplicationType(AppType = ApplicationType.Web)] [DataSourcePropertyTypeTargetAttribute(DataSourcePropertyType.AllDb)] [Netcad.Web.Controls.NetigmaHelpId(40)] public class CheckBoxFormPropertyEditor : FormPropertyEditorBase, INetigma1ControlPropertyReader, ISupportClientSideScripts { [ml_DisplayName(2, "Adı")] [NetigmaNonSerialized] [Browsable(false)] public override string Name { get { return "CheckBox"; } } [ml_DisplayName(3, "Gösterim Adı")] [NetigmaNonSerialized] public override string DisplayName { get { return ml.ml_string(309, "Seçim Kutusu"); } } [ml_DisplayName(5, "Varsayılan Değer")] public bool DefaultChecked { get; set; } public CheckBoxFormPropertyEditor() { DefaultChecked = true; } [NonSerialized] private StandartControlProperties _ControlPropertiesObject = null; [ml_DisplayName(7, "Kontrol Özellikleri")] [TypeConverter(typeof(ExpandableObjectConverter))] public StandartControlProperties ControlPropertiesObject { get { if (_ControlPropertiesObject == null) _ControlPropertiesObject = new StandartControlProperties(); return _ControlPropertiesObject; } } public void UpdatePropertiesFromNetigma1Meta(string ControlProperties) { ControlPropertiesObject.UpdateFromOldNetigmaString(ControlProperties); if (!string.IsNullOrWhiteSpace(ControlProperties)) { Netcad.Web.UI.StringParser.ParameterParser parser = new Netcad.Web.UI.StringParser.ParameterParser(ControlProperties); if (!string.IsNullOrWhiteSpace(parser["Checked"])) { this.DefaultChecked = parser["Checked"] == "1" || "true".Equals(parser["Checked"]); } } } public override object CreateControl(IDataSourceProperty owner, INetigmaDomain netigmaDomain, IGUIState state) { NetigmaCheckbox result = new NetigmaCheckbox(); result.ID = owner.Path.GetIdString(); result.Checked = this.DefaultChecked; // default state of a checkbox is checked ControlPropertiesObject.UpdateControl(result); result.Enabled = !ControlPropertiesObject.ReadOnly; return result; } public override void SetValue(object control, IDataSourceProperty owner, INetigmaDomain netigmaDomain, DataRow row) { if (row == null) return; NetigmaCheckbox cb = control as NetigmaCheckbox; object val = row[owner.Name]; if (val != null && (val.ToString() == "1" || val.ToString().Equals("True", StringComparison.InvariantCultureIgnoreCase))) cb.Checked = true; else if (row.RowState == DataRowState.Added) cb.Checked = this.DefaultChecked; else cb.Checked = false; } public override void UpdateDatabase(object control, IDataSourceProperty owner, INetigmaDomain netigmaDomain, DataRow row) { if (row == null) return; NetigmaCheckbox cb = control as NetigmaCheckbox; row[owner.Name] = cb.Checked ? 1 : 0; } public override IPropertyEditor Clone() { return new CheckBoxFormPropertyEditor(); } [TypeConverter(typeof(ExpandableObjectConverter))] public override IValidation Validator { get { return null; /* a checkbox requires no validation*/ } } [Browsable(false)] public override string IconResourcePath { get { return "Netcad.Netigma.Web.EmbededResource.Images.editorIcons.CheckBoxFormEditor.png"; } } public string GetValueScript(object control) { NetigmaCheckbox cb = control as NetigmaCheckbox; return string.Format("function(){{ return $('#{0}').prop('checked');}}", cb.ClientID); } public string SetValueScript(object control) { NetigmaCheckbox cb = control as NetigmaCheckbox; return string.Format("function(value){{$('#{0}').prop('checked',value);}}", cb.ClientID); } public string ChangeValueScript(object control) { NetigmaCheckbox cb = control as NetigmaCheckbox; return string.Format("$('#{0}').change({1}.ValueChanged);", cb.ClientID, ScriptOptions.ClientInstanceName); } public string ChangeEnableScript(object control) { NetigmaCheckbox cb = control as NetigmaCheckbox; return string.Format("function(value){{if(!value){{$('#{0}').attr('disabled','disabled');}} else {{ $('#{0}').removeAttr('disabled')}} }}", cb.ClientID); } public string JqueryObjectScript(object control) { NetigmaCheckbox cb = control as NetigmaCheckbox; return string.Format("function(){{ return $('#{0}');}}", cb.ClientID); } } } |
Target Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family, Windows Vista, Windows Server 2008 family