private void InitDropDown(BrandMetadataSelectableSetting selSetting) { var dd = new MetadataDropDownList { BrandId = BrandId, GroupNumber = GroupNumber, OmitBlankItem = false, BlankText = "Not Specified", BlankValue = "0", CssClass = "formInput W225", LinearOutlay = selSetting.IsLinear, //adding the ID of the control prevents problems with retrieving the posted back //data not being persisted to the meta input underlying controls //in a scenario when they are dynamically added to another control ID = "MetaDropDown" + PrepareID(), SortType = (SelectableMetadataSortType)selSetting.SortType }; dd.RefreshFromDataSource(); Controls.Add(dd); }
private void InitPresetTextArea(BrandMetadataSelectableSetting selSetting) { //=== add dropdown var dd = new MetadataDropDownList { BrandId = BrandId, GroupNumber = GroupNumber, OmitBlankItem = false, BlankText = "Select to populate", BlankValue = "0", CssClass = "presetDropDown formInput W225", LinearOutlay = selSetting.IsLinear, //adding the ID of the control prevents problems with retrieving the posted back //data not being persisted to the meta input underlying controls //in a scenario when they are dynamically added to another control ID = "MetadataDropDownList" + PrepareID() }; dd.RefreshFromDataSource(); Controls.Add(dd); //=== add the line break and then the text area Controls.Add(new Literal() { Text = "<br />" }); var ta = new TextArea() { CssClass = "PanelTxt W225", Rows = 6, Columns = 30, //Width = "", //adding the ID of the control prevents problems with retrieving the posted back //data not being persisted to the meta input underlying controls //in a scenario when they are dynamically added to another control ID = "MetadataTextArea" + PrepareID() }; Controls.Add(ta); //=== add the javascript/jquery logic for the presets selection //this is the url the ajax function will be calling to fetch back the respective metadata upon preset change var url = SiteUtils.GetWebsiteUrl("~/MetadataGetTextPreset.ashx?metadataId="); //ensure there is jquery included on the page if (IncludeJqueryReference) { Page.ClientScript.RegisterClientScriptInclude("jqueryinclude", "/Includes/Javascript/jQuery/jquery-1.4.1.min.js"); } //function gets metadata val upon dropdown change and inserts it into the text area var script = String.Format(@" $(document).ready(function(){{ var url = '{0}'; $('.presetDropDown').change(function(){{ var metaId = $(this).val(); var tarea = $(this).parent().find('textarea');//nextAll('textarea'); $.get(url + metaId, function(data){{ $(tarea).val(data); }}); return false; }}); }} );", url); Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "dropdownPresets", script, true); }