/// <summary> /// Create the control representing the picklist. /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { _picklist = new PickListControl(); if ((_storageMode & PicklistStorageMode.Id) != 0) { _picklist.StorageMode = Sage.Platform.Controls.StorageModeEnum.ID; } else if ((_storageMode & PicklistStorageMode.Code) != 0) { _picklist.StorageMode = Sage.Platform.Controls.StorageModeEnum.Code; } _picklist.PickListName = _picklistName; _picklist.AllowMultiples = _attr.AllowMultiples; _picklist.AlphaSort = _attr.AlphaSorted; _picklist.NoneEditable = _attr.NoneEditable; // do not set this attribute - the default validator created is too limited //_picklist.Required = _attr.Required; _picklist.MustExistInList = _attr.ValueMustExist; _picklist.PickListValueChanged += delegate { if (TextChanged != null) { TextChanged(this, EventArgs.Empty); } }; _picklist.AutoPostBack = parentControl.AutoPostBack; parentControl.Controls.Add(_picklist); }
/// <summary> /// CreateChildControls /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { _dropdown = new BindableDropDownList(); _dropdown.AppendDataBoundItems = true; _dropdown.Items.Add(new ListItem { Text = "", Value = "" }); foreach (var i in _items) { _dropdown.Items.Add(new ListItem(i.Text, i.Value)); } _dropdown.EnableViewState = false; _dropdown.SelectedIndexChanged += delegate { if (TextChanged != null) { TextChanged(this, EventArgs.Empty); } // we have to reset the value here, otherwise the dropdown will keep using the // cached value from its viewstate // (this comes from the fact that we are maintaining the state for the adapter itself // but the dropdown's viewstate is disabled) _dropdown.SelectedValue = _dropdown.SelectedValue; }; _dropdown.AutoPostBack = parentControl.AutoPostBack; parentControl.Controls.Add(_dropdown); }
/// <summary> /// CreateChildControls /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { _textbox = new TextBox(); _textbox.ID = "txt"; _textbox.ReadOnly = parentControl.ReadOnly; _textbox.AutoPostBack = parentControl.AutoPostBack; _textbox.TextChanged += delegate { if (TextChanged != null) { TextChanged(this, EventArgs.Empty); } }; parentControl.Controls.Add(_textbox); }
/// <summary> /// Create the associated listbox and send the required javascript. /// </summary> /// <param name="parentControl"></param> private void CreateChildListBox(SimplePicklist parentControl) { Panel lstContainer = new Panel(); ListBox lst = new ListBox(); lst.ID = "lst"; if (!_attr.Required) { lst.Items.Add(new ListItem("", "")); } foreach (var i in _items) { lst.Items.Add(new ListItem(i.Text, i.Value)); } if (_attr.AllowMultiples) { lst.SelectionMode = ListSelectionMode.Multiple; } lst.Style["width"] = "100%"; lst.Rows = 8; lst.EnableViewState = false; if (_attr.ValueMustExist) { lstContainer.Style.Add(HtmlTextWriterStyle.Top, "0px"); } else { lstContainer.Style.Add(HtmlTextWriterStyle.Top, "24px"); } lstContainer.Style["width"] = "100%"; lstContainer.Style.Add(HtmlTextWriterStyle.Position, "absolute"); lstContainer.Style.Add(HtmlTextWriterStyle.Left, "0px"); lstContainer.Style.Add(HtmlTextWriterStyle.Display, "none"); lstContainer.Style.Add(HtmlTextWriterStyle.ZIndex, "999"); lstContainer.Controls.Add(lst); parentControl.Controls.Add(lstContainer); ScriptManager.RegisterClientScriptBlock(parentControl, parentControl.GetType(), "Pkl$" + parentControl.ClientID, "OpenSlx_MultiSelectPicklist('" + _textbox.ClientID + "','" + lstContainer.ClientID + "','" + lst.ClientID + "');", true); }
/// <summary> /// Create the textbox, associated select control, and send the javascript needed to control them. /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { parentControl.Style["position"] = "relative"; parentControl.Style["top"] = "0px"; parentControl.Style["left"] = "0px"; _textbox = new TextBox(); _textbox.ID = "txt"; _textbox.TextChanged += delegate { if (TextChanged != null) { TextChanged(this, EventArgs.Empty); } }; _textbox.AutoPostBack = parentControl.AutoPostBack; // CANNOT set this here, because it will prevent the TextChanged event from firing //_textbox.ReadOnly = _attr.ValueMustExist; parentControl.Controls.Add(_textbox); CreateChildListBox(parentControl); }
/// <summary> /// Create the control representing the picklist. /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { _picklist = new PickListControl(); if ((_storageMode & PicklistStorageMode.Id) != 0) _picklist.StorageMode = Sage.Platform.Controls.StorageModeEnum.ID; else if ((_storageMode & PicklistStorageMode.Code) != 0) _picklist.StorageMode = Sage.Platform.Controls.StorageModeEnum.Code; _picklist.PickListName = _picklistName; _picklist.AllowMultiples = _attr.AllowMultiples; _picklist.AlphaSort = _attr.AlphaSorted; _picklist.NoneEditable = _attr.NoneEditable; // do not set this attribute - the default validator created is too limited //_picklist.Required = _attr.Required; _picklist.MustExistInList = _attr.ValueMustExist; _picklist.PickListValueChanged += delegate { if (TextChanged != null) TextChanged(this, EventArgs.Empty); }; _picklist.AutoPostBack = parentControl.AutoPostBack; parentControl.Controls.Add(_picklist); }
/// <summary> /// Create the textbox, associated select control, and send the javascript needed to control them. /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { parentControl.Style["position"] = "relative"; parentControl.Style["top"] = "0px"; parentControl.Style["left"] = "0px"; _textbox = new TextBox(); _textbox.ID = "txt"; _textbox.TextChanged += delegate { if (TextChanged != null) TextChanged(this, EventArgs.Empty); }; _textbox.AutoPostBack = parentControl.AutoPostBack; // CANNOT set this here, because it will prevent the TextChanged event from firing //_textbox.ReadOnly = _attr.ValueMustExist; parentControl.Controls.Add(_textbox); CreateChildListBox(parentControl); }
/// <summary> /// Create the associated listbox and send the required javascript. /// </summary> /// <param name="parentControl"></param> private void CreateChildListBox(SimplePicklist parentControl) { Panel lstContainer = new Panel(); ListBox lst = new ListBox(); lst.ID = "lst"; if (!_attr.Required) lst.Items.Add(new ListItem("", "")); foreach (var i in _items) { lst.Items.Add(new ListItem(i.Text, i.Value)); } if (_attr.AllowMultiples) lst.SelectionMode = ListSelectionMode.Multiple; lst.Style["width"] = "100%"; lst.Rows = 8; lst.EnableViewState = false; if (_attr.ValueMustExist) lstContainer.Style.Add(HtmlTextWriterStyle.Top, "0px"); else lstContainer.Style.Add(HtmlTextWriterStyle.Top, "24px"); lstContainer.Style["width"] = "100%"; lstContainer.Style.Add(HtmlTextWriterStyle.Position, "absolute"); lstContainer.Style.Add(HtmlTextWriterStyle.Left, "0px"); lstContainer.Style.Add(HtmlTextWriterStyle.Display, "none"); lstContainer.Style.Add(HtmlTextWriterStyle.ZIndex, "999"); lstContainer.Controls.Add(lst); parentControl.Controls.Add(lstContainer); ScriptManager.RegisterClientScriptBlock(parentControl, parentControl.GetType(), "Pkl$" + parentControl.ClientID, "OpenSlx_MultiSelectPicklist('" + _textbox.ClientID + "','" + lstContainer.ClientID + "','" + lst.ClientID + "');", true); }
/// <summary> /// CreateChildControls /// </summary> /// <param name="parentControl"></param> public void CreateChildControls(SimplePicklist parentControl) { _dropdown = new BindableDropDownList(); _dropdown.AppendDataBoundItems = true; _dropdown.Items.Add(new ListItem { Text = "", Value = "" }); foreach (var i in _items) { _dropdown.Items.Add(new ListItem(i.Text, i.Value)); } _dropdown.EnableViewState = false; _dropdown.SelectedIndexChanged += delegate { if (TextChanged != null) TextChanged(this, EventArgs.Empty); // we have to reset the value here, otherwise the dropdown will keep using the // cached value from its viewstate // (this comes from the fact that we are maintaining the state for the adapter itself // but the dropdown's viewstate is disabled) _dropdown.SelectedValue = _dropdown.SelectedValue; }; _dropdown.AutoPostBack = parentControl.AutoPostBack; parentControl.Controls.Add(_dropdown); }