Don't miss out Virtual Happy Hour today (April 26).

Try our conversational search powered by Generative AI!

Drop down customization in Edit Mode

Vote:
 
Hi I need help on Drop down customization in Edit Mode. There are two drop downs. On selecting an item in the first dropdown the second dropdown must be populated according to the selected value in the first dropdown. I have used Sessions for this. I've explained the flow below. On selecting an item from the first dropdown, the selected value is stored in a session and the page undergoes post back and the dropdowns are again populated freshly. The dropdown controls are first populated after which the selected index change event is called. Due to this the second dropdown is populated based on the previous selected value in the session. I've added the code below. Request your help at the earliest. #region OnlineFormTypeControl public class OnlineFormTypeControl : EPiServer.Web.PropertyControls.PropertySelectControlBase { protected override void SetupEditControls() { try { EditControl.AutoPostBack = true; EditControl.EnableViewState = true; EditControl.SelectedIndexChanged += new EventHandler(EditControl_SelectedIndexChanged); if (EditControl.Items.Count <= 0) { editcontrol.items.add( new listitem("polling", "polling")); editcontrol.items.add( new listitem("feedback", "feedback")); } if (editcontrol.selectedvalue !="null)" editcontrol.selectedvalue="OnlineFT.Value.ToString();" clientscript. scriptmanager.current.addeventlistener(editcontrol, new clientscript.events.disablepageleaveevent(clientscript.eventtype.change)); editcontrol.attributes.add("onchange",">" ); } catch (Exception ex) { HttpContext.Current.Response.Write(ex); throw ex; } } void EditControl_SelectedIndexChanged(object sender, EventArgs e) { HttpContext.Current.Session[GlobalConstants.CONST_SESSION_DDLFORMTYPE] = EditControl.SelectedItem.Value; } public OnlineFormType OnlineFT { get { return PropertyData as OnlineFormType; } } } #endregion #region OnlineReportTypeControl public class OnlineReportTypeControl : EPiServer.Web.PropertyControls.PropertySelectControlBase { protected override void SetupEditControls() { try { if (HttpContext.Current.Session[GlobalConstants.CONST_SESSION_DDLFORMTYPE] != null) { if (HttpContext.Current.Session[GlobalConstants.CONST_SESSION_DDLFORMTYPE].ToString() == "Polling") { EditControl.Items.Add( new ListItem("Statistical Result", "Statistical")); EditControl.Items.Add( new ListItem("Graphical Result", "Graphical")); EditControl.Items.Add( new ListItem("Statistical and Graphical Result", "Statistical_Graphical")); } else EditControl.Items.Add( new ListItem("QA/General Report", "General")); HttpContext.Current.Session["sFormTypeDropDown"] = null; } //if (EditControl.SelectedValue != null) // EditControl.SelectedValue = OnlineReport.Value.ToString(); } catch (Exception ex) { HttpContext.Current.Response.Write(ex); throw ex; } } public OnlineReportType OnlineReport { get { return PropertyData as OnlineReportType; } } } #endregion
#16025
Mar 11, 2008 6:19
Vote:
 
Hi! I'm not sure what problem you are facing but I would recomend to have one property control that does all logic and saves the values to two properties. The values can be saved like this: protected override void ApplyEditChanges() { //Set the value for this property object firstValue = GetFirstValue(); object secondValue = GetSecondValue(); SetValue(firstValue); PropertyData secondProperty = Properties[Name + "_additionalProperty"];//"_additionalProperty" is just some name to find the second property SetValue(secondValue, secondProperty); } You can read about properties in the sdk here: http://sdk.episerver.com/library/cms5/index.aspx?ContentFrame=http://sdk.episerver.com/library/cms5/Developers%20Guide/Web%20Controls/Property%20Types.htm
#16839
Mar 13, 2008 10:14
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.