protected override void CreateChildControls() { base.CreateChildControls(); Label lblQuestion = new Label(); _dpAnswer = new DatePickerControl(); _dpAnswer.Text = _answer; RequiredFieldValidator valQuestion = new RequiredFieldValidator(); lblQuestion.ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty);; _dpAnswer.ID = "dp" + _question.QuestionGuid.ToString().Replace("-", String.Empty); valQuestion.ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty); lblQuestion.Text = _question.QuestionText; lblQuestion.AssociatedControlID = _dpAnswer.ID; valQuestion.ControlToValidate = _dpAnswer.ID; valQuestion.Enabled = _question.AnswerIsRequired; valQuestion.Text = _question.ValidationMessage; Controls.Add(lblQuestion); Controls.Add(_dpAnswer); Controls.Add(valQuestion); }
public DatePickerElement(UIElement <Control> other) { _control = new DatePickerControl(); other.Element.Margin = Padding.Empty; _control.Other = other; other.Changed += (s, e) => OnChanged(); other.Search += (s, e) => OnSearch(); Element = _control; }
protected void grdPages_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (sender == null) { return; } if (e == null) { return; } GridView grid = (GridView)sender; int pageID = (int)grid.DataKeys[e.RowIndex].Value; CheckBox chkPublish = (CheckBox)grid.Rows[e.RowIndex].Cells[2].FindControl("chkPublished"); DropDownList ddPanes = (DropDownList)grid.Rows[e.RowIndex].Cells[2].FindControl("ddPaneNames"); TextBox txtOrder = (TextBox)grid.Rows[e.RowIndex].Cells[3].FindControl("txtModuleOrder"); DatePickerControl dpBegin = (DatePickerControl)grid.Rows[e.RowIndex].Cells[4].FindControl("dpBeginDate"); DatePickerControl dpEnd = (DatePickerControl)grid.Rows[e.RowIndex].Cells[4].FindControl("dpEndDate"); String paneName = ddPanes.SelectedValue; int moduleOrder = int.Parse(txtOrder.Text, CultureInfo.InvariantCulture); DateTime beginDate = DateTime.Parse(dpBegin.Text).AddHours(-timeOffset); DateTime endDate = dpEnd.Text.Length > 0 ? DateTime.Parse(dpEnd.Text).AddHours(-timeOffset) : DateTime.MinValue; PageSettings currentPage = new PageSettings(siteSettings.SiteId, pageID); currentModule = new Module(moduleID); if (chkPublish.Checked) { Module.Publish( currentPage.ParentGuid, currentModule.ModuleGuid, currentModule.ModuleId, pageID, paneName, moduleOrder, beginDate, endDate); } else { Module.DeleteModuleInstance(this.moduleID, pageID); } // rebuild page search index currentPage.PageIndex = CurrentPage.PageIndex; IndexHelper.RebuildPageIndexAsync(currentPage); WebUtils.SetupRedirect(this, Request.RawUrl); }
public override void OnApplyTemplate() { monthControl = this.GetTemplateChild("MonthControl") as MonthControl; dateModel = monthControl is MonthGridControl ? new DateMonthModel() : new DateRangeModel(); datePickerControl = this.GetTemplateChild("DatePickerControl") as DatePickerControl; dualButtonControl = this.GetTemplateChild("DualButtonControl") as DualButtonControl; monthGrid = this.GetTemplateChild("MonthGrid") as Grid; SetGridType((GridType)dualButtonControl.ValueToKey()); datePickerControl.Month = dateModel.Month; datePickerControl.Year = dateModel.Year; //if (dualButtonControl.IsLoaded) //{ //sdg(); //} //else //{ // dualButtonControl.Loaded += (_, _) => sdg(); //} dualButtonControl.ButtonToggle += DualButtonControl_ButtonToggle; this.SelectedItem = monthControl.SelectedItem; datePickerControl.DateChange += DatePickerControl_DateChange; void sdg() { SetGridType((GridType)dualButtonControl.ValueToKey()); datePickerControl.Month = dateModel.Month; datePickerControl.Year = dateModel.Year; //SetMonthControl(monthControl); //monthControl.ItemsSource = dateModel.Days; //monthControl.SelectedItem = dateModel.Current; // dateModel.PropertyChanged += DateModel_PropertyChanged; } base.OnApplyTemplate(); void DatePickerControl_DateChange(object sender, DateChangeEventArgs e) { dateModel.Month = e.Month; dateModel.Year = e.Year; monthControl.ItemsSource = dateModel.Days; monthControl.SelectedItem = dateModel.Current; } }
private static DatePickerControl CreateDatePicker( CProfilePropertyDefinition propertyDefinition, String propertyValue, Double timeZoneOffset, string siteRoot) { DatePickerControl datePicker = new DatePickerControl(); datePicker.ID = "dp" + propertyDefinition.Name; if (propertyValue.Length > 0) { DateTime dt; if (DateTime.TryParse( propertyValue, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out dt)) { if (propertyDefinition.IncludeTimeForDate) { dt = dt.AddHours(timeZoneOffset); datePicker.Text = dt.ToString(); } else { datePicker.Text = dt.Date.ToShortDateString(); } } else { datePicker.Text = propertyValue; } } else { if (propertyDefinition.DefaultValue.Length > 0) { datePicker.Text = propertyDefinition.DefaultValue; } } datePicker.ShowTime = propertyDefinition.IncludeTimeForDate; return(datePicker); }
protected override void CreateChildControls() { base.CreateChildControls(); _dpAnswer = new DatePickerControl { ID = "dp" + _question.QuestionGuid.ToString().Replace("-", String.Empty), Text = _answer, SkinID = "Survey" }; Label lblQuestion = new Label { ID = "lbl" + _question.QuestionGuid.ToString().Replace("-", String.Empty), CssClass = "settinglabel", Text = _question.QuestionName, AssociatedControlID = _dpAnswer.ID }; Literal litQuestionText = new Literal { Text = _question.QuestionText }; RequiredFieldValidator valQuestion = new RequiredFieldValidator { ID = "val" + _question.QuestionGuid.ToString().Replace("-", String.Empty), Text = _question.ValidationMessage, Enabled = _question.AnswerIsRequired, ControlToValidate = _dpAnswer.ID }; Controls.Add(lblQuestion); Controls.Add(litQuestionText); Controls.Add(_dpAnswer); Controls.Add(valQuestion); }
protected void grdPages_RowUpdating(object sender, GridViewUpdateEventArgs e) { if (sender == null) { return; } if (e == null) { return; } GridView grid = (GridView)sender; int pageID = (int)grid.DataKeys[e.RowIndex].Value; CheckBox chkPublish = (CheckBox)grid.Rows[e.RowIndex].Cells[2].FindControl("chkPublished"); DropDownList ddPanes = (DropDownList)grid.Rows[e.RowIndex].Cells[2].FindControl("ddPaneNames"); TextBox txtOrder = (TextBox)grid.Rows[e.RowIndex].Cells[3].FindControl("txtModuleOrder"); DatePickerControl dpBegin = (DatePickerControl)grid.Rows[e.RowIndex].Cells[4].FindControl("dpBeginDate"); DatePickerControl dpEnd = (DatePickerControl)grid.Rows[e.RowIndex].Cells[4].FindControl("dpEndDate"); string paneName = ddPanes.SelectedValue; int moduleOrder = int.Parse(txtOrder.Text, CultureInfo.InvariantCulture); DateTime beginDate; DateTime endDate; Boolean beginDateInvalid = false; if (!DateTime.TryParse(dpBegin.Text, out beginDate)) { beginDateInvalid = true; } if (dpEnd.Text.Length > 0) { if (!DateTime.TryParse(dpEnd.Text, out endDate)) { endDate = DateTime.MinValue; } } else { endDate = DateTime.MinValue; } if (timeZone != null) { beginDate = beginDateInvalid ? DateTime.UtcNow.ToLocalTime(timeZone) : beginDate.ToUtc(timeZone); if (endDate != DateTime.MinValue) { endDate = endDate.ToUtc(timeZone); } } else { beginDate = beginDateInvalid ? DateTime.Now.AddHours(-timeOffset) : beginDate.AddHours(-timeOffset); if (endDate != DateTime.MinValue) { endDate = endDate.AddHours(-timeOffset); } } PageSettings currentPage = new PageSettings(siteSettings.SiteId, pageID); //currentModule = new Module(moduleID); if (chkPublish.Checked) { Module.Publish( currentPage.PageGuid, currentModule.ModuleGuid, currentModule.ModuleId, pageID, paneName, moduleOrder, beginDate, endDate); } else { if (WebConfigSettings.LogIpAddressForContentDeletions) { Module m = new Module(moduleID); PageSettings contentPage = new PageSettings(siteSettings.SiteId, pageID); string userName = string.Empty; SiteUser currentUser = SiteUtils.GetCurrentSiteUser(); if (currentUser != null) { userName = currentUser.Name; } log.Info("user " + userName + " removed module " + m.ModuleTitle + " from page " + contentPage.PageName + " from ip address " + SiteUtils.GetIP4Address()); } Module.DeleteModuleInstance(this.moduleID, pageID); } // rebuild page search index currentPage.PageIndex = CurrentPage.PageIndex; mojoPortal.SearchIndex.IndexHelper.RebuildPageIndexAsync(currentPage); WebUtils.SetupRedirect(this, Request.RawUrl); }
public static void SaveProperty( SiteUser siteUser, Panel parentControl, mojoProfilePropertyDefinition propertyDefinition, Double legacyTimeZoneOffset, TimeZoneInfo timeZone) { String controlID; Control control; if (propertyDefinition.ISettingControlSrc.Length > 0) { controlID = "isc" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { siteUser.SetProperty( propertyDefinition.Name, ((ISettingControl)control).GetValue(), propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } else { switch (propertyDefinition.Type) { case "System.Boolean": controlID = "chk" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { siteUser.SetProperty( propertyDefinition.Name, ((CheckBox)control).Checked, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } break; case "System.DateTime": controlID = "dp" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { DatePickerControl dp = (DatePickerControl)control; if (dp.Text.Length > 0) { DateTime dt; if (DateTime.TryParse( dp.Text, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out dt)) { if (propertyDefinition.IncludeTimeForDate) { if (timeZone != null) { dt = dt.ToUtc(timeZone); } else { dt = dt.AddHours(-legacyTimeZoneOffset); } if (propertyDefinition.Name == "DateOfBirth") { siteUser.DateOfBirth = dt.Date; siteUser.Save(); } else { siteUser.SetProperty( propertyDefinition.Name, dt.ToString(), propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } else { if (propertyDefinition.Name == "DateOfBirth") { siteUser.DateOfBirth = dt.Date; siteUser.Save(); } else { siteUser.SetProperty( propertyDefinition.Name, dt.Date.ToShortDateString(), propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } } else { siteUser.SetProperty( propertyDefinition.Name, dp.Text, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } else // blank { if (propertyDefinition.Name == "DateOfBirth") { siteUser.DateOfBirth = DateTime.MinValue; siteUser.Save(); } else { siteUser.SetProperty( propertyDefinition.Name, String.Empty, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } } break; case "System.String": default: if (propertyDefinition.OptionList.Count > 0) { if (propertyDefinition.Type == "CheckboxList") { controlID = "cbl" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { if (control is CheckBoxList) { CheckBoxList cbl = (CheckBoxList)control; siteUser.SetProperty( propertyDefinition.Name, cbl.Items.SelectedItemsToCommaSeparatedString(), propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } } else { controlID = "dd" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { if (control is DropDownList) { DropDownList dd = (DropDownList)control; if (dd.SelectedIndex > -1) { siteUser.SetProperty( propertyDefinition.Name, dd.SelectedValue, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } } } } else { controlID = "txt" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { siteUser.SetProperty( propertyDefinition.Name, ((TextBox)control).Text, propertyDefinition.SerializeAs, propertyDefinition.LazyLoad); } } break; } } }
private static DatePickerControl CreateDatePicker( mojoProfilePropertyDefinition propertyDefinition, String propertyValue, Double legacyTimeZoneOffset, TimeZoneInfo timeZone, string siteRoot) { DatePickerControl datePicker = new DatePickerControl(); try { datePicker.SkinID = propertyDefinition.Name.Replace(" ", string.Empty); } catch (ArgumentException) { } datePicker.ID = "dp" + propertyDefinition.Name; datePicker.ShowMonthList = propertyDefinition.DatePickerShowMonthList; datePicker.ShowYearList = propertyDefinition.DatePickerShowYearList; if (propertyDefinition.DatePickerYearRange.Length > 0) { datePicker.YearRange = propertyDefinition.DatePickerYearRange; } if (propertyValue.Length > 0) { DateTime dt; if (DateTime.TryParse( propertyValue, CultureInfo.CurrentCulture, DateTimeStyles.AdjustToUniversal, out dt)) { if (propertyDefinition.IncludeTimeForDate) { if (timeZone != null) { dt = dt.ToLocalTime(timeZone); } else { dt = dt.AddHours(legacyTimeZoneOffset); } datePicker.Text = dt.ToString("g"); } else { datePicker.Text = dt.Date.ToShortDateString(); } } else { datePicker.Text = propertyValue; } } else { if (propertyDefinition.DefaultValue.Length > 0) { datePicker.Text = propertyDefinition.DefaultValue; } } datePicker.ShowTime = propertyDefinition.IncludeTimeForDate; return(datePicker); }
public static void SetupPropertyControl( Page currentPage, Panel parentControl, mojoProfilePropertyDefinition propertyDefinition, String propertyValue, Double legacyTimeZoneOffset, TimeZoneInfo timeZone, string siteRoot) { if (propertyValue == null) { propertyValue = String.Empty; } string validatorSkinID = "Profile"; if (currentPage is mojoPortal.Web.UI.Pages.Register) { validatorSkinID = "Registration"; } Literal rowOpenTag = new Literal(); rowOpenTag.Text = "<div class='settingrow " + propertyDefinition.CssClass + "'>"; parentControl.Controls.Add(rowOpenTag); SiteLabel label = new SiteLabel(); label.ResourceFile = propertyDefinition.ResourceFile; // if key isn't in resource file use assume the resource hasn't been //localized and just use the key as the resource label.ShowWarningOnMissingKey = false; label.ConfigKey = propertyDefinition.LabelResourceKey; label.CssClass = "settinglabel"; if (propertyDefinition.ISettingControlSrc.Length > 0) { Control c = null; if (propertyDefinition.ISettingControlSrc.EndsWith(".ascx")) { c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc); } else { try { c = Activator.CreateInstance(System.Type.GetType(propertyDefinition.ISettingControlSrc)) as Control; } catch (Exception ex) { log.Error(ex); } } if ((c != null) && (c is ISettingControl)) { c.ID = "isc" + propertyDefinition.Name; parentControl.Controls.Add(label); ISettingControl settingControl = (ISettingControl)c; settingControl.SetValue(propertyValue); parentControl.Controls.Add(c); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } } } else if (propertyDefinition.OptionList.Count > 0) { if (propertyDefinition.Type == "CheckboxList") { CheckBoxList cbl = CreateCheckBoxListQuestion(propertyDefinition, propertyValue); cbl.ID = "cbl" + propertyDefinition.Name; cbl.EnableTheming = false; cbl.CssClass = "forminput"; cbl.TabIndex = 10; label.ForControl = cbl.ID; parentControl.Controls.Add(label); parentControl.Controls.Add(cbl); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyDefinition.RequiredForRegistration) { CheckBoxListValidator rfv = new CheckBoxListValidator(); rfv.SkinID = validatorSkinID; rfv.ControlToValidate = cbl.ID; rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat, ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey)); //rfv.Display = ValidatorDisplay.None; rfv.ValidationGroup = "profile"; parentControl.Controls.Add(rfv); } } else { // add a dropdownlist with the options DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue); dd.ID = "dd" + propertyDefinition.Name; dd.EnableTheming = false; dd.CssClass = "forminput " + propertyDefinition.CssClass; dd.TabIndex = 10; label.ForControl = dd.ID; parentControl.Controls.Add(label); parentControl.Controls.Add(dd); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyDefinition.RequiredForRegistration) { RequiredFieldValidator rfvDd = new RequiredFieldValidator(); rfvDd.SkinID = validatorSkinID; rfvDd.ControlToValidate = dd.ID; //if(dd.Items.Count > 0) //{ // rfvDd.InitialValue = dd.Items[0].Value; //} rfvDd.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat, ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey)); rfvDd.ValidationGroup = "profile"; parentControl.Controls.Add(rfvDd); } if (propertyDefinition.RegexValidationExpression.Length > 0) { RegularExpressionValidator regexValidator = new RegularExpressionValidator(); regexValidator.SkinID = validatorSkinID; regexValidator.ControlToValidate = dd.ID; regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression; regexValidator.ValidationGroup = "profile"; if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0) { regexValidator.ErrorMessage = ResourceHelper.GetResourceString( propertyDefinition.ResourceFile, propertyDefinition.RegexValidationErrorResourceKey); } //regexValidator.Display = ValidatorDisplay.None; parentControl.Controls.Add(regexValidator); } } } else { switch (propertyDefinition.Type) { case "System.Boolean": CheckBox checkBox = new CheckBox(); checkBox.TabIndex = 10; checkBox.ID = "chk" + propertyDefinition.Name; checkBox.CssClass = "forminput " + propertyDefinition.CssClass; label.ForControl = checkBox.ID; parentControl.Controls.Add(label); parentControl.Controls.Add(checkBox); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyValue.ToLower() == "true") { checkBox.Checked = true; } break; case "System.DateTime": // TODO: to really make this culture aware we should store the users // culture as well and use the user's culture to // parse the date DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, legacyTimeZoneOffset, timeZone, siteRoot); datePicker.TabIndex = 10; datePicker.ID = "dp" + propertyDefinition.Name; datePicker.CssClass = "forminput " + propertyDefinition.CssClass; parentControl.Controls.Add(label); parentControl.Controls.Add(datePicker); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyDefinition.RequiredForRegistration) { RequiredFieldValidator rfvDate = new RequiredFieldValidator(); rfvDate.SkinID = validatorSkinID; rfvDate.ControlToValidate = datePicker.ID; rfvDate.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat, ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey)); //rfvDate.Display = ValidatorDisplay.None; rfvDate.ValidationGroup = "profile"; parentControl.Controls.Add(rfvDate); } if (propertyDefinition.RegexValidationExpression.Length > 0) { RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator(); regexValidatorDate.SkinID = validatorSkinID; regexValidatorDate.ControlToValidate = datePicker.ID; regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression; regexValidatorDate.ValidationGroup = "profile"; if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0) { regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString( propertyDefinition.ResourceFile, propertyDefinition.RegexValidationErrorResourceKey); } //regexValidatorDate.Display = ValidatorDisplay.None; parentControl.Controls.Add(regexValidatorDate); } break; case "System.String": default: TextBox textBox = new TextBox(); textBox.TabIndex = 10; textBox.ID = "txt" + propertyDefinition.Name; textBox.CssClass = "forminput " + propertyDefinition.CssClass; label.ForControl = textBox.ID; parentControl.Controls.Add(label); if (propertyDefinition.MaxLength > 0) { textBox.MaxLength = propertyDefinition.MaxLength; } if (propertyDefinition.Columns > 0) { textBox.Columns = propertyDefinition.Columns; } if (propertyDefinition.Rows > 1) { textBox.TextMode = TextBoxMode.MultiLine; textBox.Rows = propertyDefinition.Rows; } parentControl.Controls.Add(textBox); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyValue.Length > 0) { textBox.Text = propertyValue; } if (propertyDefinition.RequiredForRegistration) { RequiredFieldValidator rfv = new RequiredFieldValidator(); rfv.SkinID = validatorSkinID; rfv.ControlToValidate = textBox.ID; rfv.ErrorMessage = string.Format(CultureInfo.InvariantCulture, Resources.ProfileResource.ProfileRequiredItemFormat, ResourceHelper.GetResourceString(propertyDefinition.ResourceFile, propertyDefinition.LabelResourceKey)); //rfv.Display = ValidatorDisplay.None; rfv.ValidationGroup = "profile"; parentControl.Controls.Add(rfv); } if (propertyDefinition.RegexValidationExpression.Length > 0) { RegularExpressionValidator regexValidator = new RegularExpressionValidator(); regexValidator.SkinID = validatorSkinID; regexValidator.ControlToValidate = textBox.ID; regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression; regexValidator.ValidationGroup = "profile"; if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0) { regexValidator.ErrorMessage = ResourceHelper.GetResourceString( propertyDefinition.ResourceFile, propertyDefinition.RegexValidationErrorResourceKey); } //regexValidator.Display = ValidatorDisplay.None; parentControl.Controls.Add(regexValidator); } break; } } Literal rowCloseTag = new Literal(); rowCloseTag.Text = "</div>"; parentControl.Controls.Add(rowCloseTag); }
public static void LoadState( Panel parentControl, mojoProfilePropertyDefinition propertyDefinition) { String controlID; Control control; switch (propertyDefinition.Type) { case "System.Boolean": controlID = "chk" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { propertyDefinition.StateValue = ((CheckBox)control).Checked.ToString(); } break; case "System.DateTime": controlID = "dp" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { DatePickerControl dp = (DatePickerControl)control; if (dp.Text.Length > 0) { propertyDefinition.StateValue = dp.Text; } } break; case "System.String": default: if (propertyDefinition.OptionList.Count > 0) { if (propertyDefinition.Type == "CheckboxList") { controlID = "cbl" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { if (control is CheckBoxList) { CheckBoxList cbl = (CheckBoxList)control; propertyDefinition.StateValue = cbl.Items.SelectedItemsToCommaSeparatedString(); } } } else { controlID = "dd" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { if (control is DropDownList) { DropDownList dd = (DropDownList)control; if (dd.SelectedIndex > -1) { propertyDefinition.StateValue = dd.SelectedValue; } } } } } else { controlID = "txt" + propertyDefinition.Name; control = parentControl.FindControl(controlID); if (control != null) { propertyDefinition.StateValue = ((TextBox)control).Text; } } break; } }
public override void OnInspectorGUI() { DrawDefaultInspector(); DatePickerControl script = (DatePickerControl)target; if (script.formato == DatePickerControl.nFormato.custom) { EditorGUILayout.PrefixLabel("Format Custom"); script.formatoCustom = EditorGUILayout.TextArea(script.formatoCustom); } else if (script.formato != DatePickerControl.nFormato.Default) { string aux = ""; aux = script.separator.ToString(); EditorGUILayout.PrefixLabel("Separator"); script.separator = EditorGUILayout.TextArea(aux)[0]; } script.dateOn = EditorGUILayout.Toggle("Date On", script.dateOn); if (script.dateOn) { script.inputFieldDate.fontSizeCustom = EditorGUILayout.ToggleLeft ("Font Size Custom", script.inputFieldDate.fontSizeCustom); script.inputFieldDate.day = EditorGUILayout.ObjectField (" InputFiel Day", script.inputFieldDate.day, typeof(InputField), true) as InputField; if (script.inputFieldDate.fontSizeCustom) { script.inputFieldDate.fontSizeDay = EditorGUILayout.IntField(" Font Size Day", script.inputFieldDate.fontSizeDay); } script.inputFieldDate.month = EditorGUILayout.ObjectField (" InputFiel Month", script.inputFieldDate.month, typeof(InputField), true) as InputField; if (script.inputFieldDate.fontSizeCustom) { script.inputFieldDate.fontSizeMonth = EditorGUILayout.IntField(" Font Size Month", script.inputFieldDate.fontSizeMonth); } script.inputFieldDate.year = EditorGUILayout.ObjectField (" InputFiel Year", script.inputFieldDate.year, typeof(InputField), true) as InputField; if (script.inputFieldDate.fontSizeCustom) { script.inputFieldDate.fontSizeYear = EditorGUILayout.IntField(" Font Size Year", script.inputFieldDate.fontSizeYear); } EditorGUILayout.Space(); } script.timeOn = EditorGUILayout.Toggle("Time On", script.timeOn); if (script.timeOn) { script.inputFieldTime.fontSizeCustom = EditorGUILayout.ToggleLeft ("Font Size Custom", script.inputFieldTime.fontSizeCustom); script.inputFieldTime.hour = EditorGUILayout.ObjectField (" InputFiel Hour", script.inputFieldTime.hour, typeof(InputField), true) as InputField; if (script.inputFieldTime.fontSizeCustom) { script.inputFieldTime.fontSizeHour = EditorGUILayout.IntField(" Font Size Hour", script.inputFieldTime.fontSizeHour); } script.inputFieldTime.minute = EditorGUILayout.ObjectField (" InputFiel Minute", script.inputFieldTime.minute, typeof(InputField), true) as InputField; if (script.inputFieldTime.fontSizeCustom) { script.inputFieldTime.fontSizeMinute = EditorGUILayout.IntField(" Font Size Minute", script.inputFieldTime.fontSizeMinute); } script.inputFieldTime.second = EditorGUILayout.ObjectField (" InputFiel Second", script.inputFieldTime.second, typeof(InputField), true) as InputField; if (script.inputFieldTime.fontSizeCustom) { script.inputFieldTime.fontSizeSecond = EditorGUILayout.IntField(" Font Size Second", script.inputFieldTime.fontSizeSecond); } EditorGUILayout.Space(); } }
void DateValueButtonClicked(object sender, System.EventArgs e) { DatePickerControl.Focus(); }
public static void SetupPropertyControl( Page currentPage, Panel parentControl, CProfilePropertyDefinition propertyDefinition, String propertyValue, Double timeZoneOffset, string siteRoot) { if (propertyValue == null) { propertyValue = String.Empty; } Literal rowOpenTag = new Literal(); rowOpenTag.Text = "<div class='settingrow'>"; parentControl.Controls.Add(rowOpenTag); SiteLabel label = new SiteLabel(); label.ResourceFile = propertyDefinition.ResourceFile; // if key isn't in resource file use assume the resource hasn't been //localized and just use the key as the resource label.ShowWarningOnMissingKey = false; label.ConfigKey = propertyDefinition.LabelResourceKey; label.CssClass = "settinglabel"; if (propertyDefinition.ISettingControlSrc.Length > 0) { Control c = currentPage.LoadControl(propertyDefinition.ISettingControlSrc); if ((c != null) && (c is ISettingControl)) { c.ID = "isc" + propertyDefinition.Name; parentControl.Controls.Add(label); ISettingControl settingControl = (ISettingControl)c; settingControl.SetValue(propertyValue); parentControl.Controls.Add(c); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } } } else if (propertyDefinition.OptionList.Count > 0) { // add a dropdownlist with the options DropDownList dd = CreateDropDownQuestion(propertyDefinition, propertyValue); dd.ID = "dd" + propertyDefinition.Name; dd.EnableTheming = false; dd.CssClass = "forminput"; dd.TabIndex = 10; label.ForControl = dd.ID; parentControl.Controls.Add(label); parentControl.Controls.Add(dd); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } } else { switch (propertyDefinition.Type) { case "System.Boolean": CheckBox checkBox = new CheckBox(); checkBox.TabIndex = 10; checkBox.ID = "chk" + propertyDefinition.Name; checkBox.CssClass = "forminput"; label.ForControl = checkBox.ID; parentControl.Controls.Add(label); parentControl.Controls.Add(checkBox); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyValue.ToLower() == "true") { checkBox.Checked = true; } break; case "System.DateTime": // TODO: to really make this culture aware we should store the users // culture as well and use the user's culture to // parse the date DatePickerControl datePicker = CreateDatePicker(propertyDefinition, propertyValue, timeZoneOffset, siteRoot); datePicker.TabIndex = 10; datePicker.ID = "dp" + propertyDefinition.Name; datePicker.CssClass = "forminput"; parentControl.Controls.Add(label); parentControl.Controls.Add(datePicker); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyDefinition.RequiredForRegistration) { RequiredFieldValidator rfvDate = new RequiredFieldValidator(); rfvDate.ControlToValidate = datePicker.ID; rfvDate.ErrorMessage = Resources.ProfileResource.RequiredLabel; rfvDate.Display = ValidatorDisplay.Dynamic; rfvDate.ValidationGroup = "profile"; parentControl.Controls.Add(rfvDate); } if (propertyDefinition.RegexValidationExpression.Length > 0) { RegularExpressionValidator regexValidatorDate = new RegularExpressionValidator(); regexValidatorDate.ControlToValidate = datePicker.ID; regexValidatorDate.ValidationExpression = propertyDefinition.RegexValidationExpression; regexValidatorDate.ValidationGroup = "profile"; if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0) { regexValidatorDate.ErrorMessage = ResourceHelper.GetResourceString( propertyDefinition.ResourceFile, propertyDefinition.RegexValidationErrorResourceKey); //object o = HttpContext.GetGlobalResourceObject( // propertyDefinition.ResourceFile, // propertyDefinition.RegexValidationErrorResourceKey); //if (o != null) //{ // regexValidatorDate.ErrorMessage = o.ToString(); //} //else //{ // regexValidatorDate.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey; //} } regexValidatorDate.Display = ValidatorDisplay.Dynamic; parentControl.Controls.Add(regexValidatorDate); } break; case "System.String": default: TextBox textBox = new TextBox(); textBox.TabIndex = 10; textBox.ID = "txt" + propertyDefinition.Name; textBox.CssClass = "forminput"; label.ForControl = textBox.ID; parentControl.Controls.Add(label); if (propertyDefinition.MaxLength > 0) { textBox.MaxLength = propertyDefinition.MaxLength; } if (propertyDefinition.Columns > 0) { textBox.Columns = propertyDefinition.Columns; } if (propertyDefinition.Rows > 1) { textBox.TextMode = TextBoxMode.MultiLine; textBox.Rows = propertyDefinition.Rows; } parentControl.Controls.Add(textBox); if (propertyDefinition.IncludeHelpLink) { AddHelpLink(parentControl, propertyDefinition); } if (propertyValue.Length > 0) { textBox.Text = propertyValue; } if (propertyDefinition.RequiredForRegistration) { RequiredFieldValidator rfv = new RequiredFieldValidator(); rfv.ControlToValidate = textBox.ID; rfv.ErrorMessage = Resources.ProfileResource.RequiredLabel; rfv.Display = ValidatorDisplay.Dynamic; rfv.ValidationGroup = "profile"; parentControl.Controls.Add(rfv); } if (propertyDefinition.RegexValidationExpression.Length > 0) { RegularExpressionValidator regexValidator = new RegularExpressionValidator(); regexValidator.ControlToValidate = textBox.ID; regexValidator.ValidationExpression = propertyDefinition.RegexValidationExpression; regexValidator.ValidationGroup = "profile"; if (propertyDefinition.RegexValidationErrorResourceKey.Length > 0) { regexValidator.ErrorMessage = ResourceHelper.GetResourceString( propertyDefinition.ResourceFile, propertyDefinition.RegexValidationErrorResourceKey); //object o = HttpContext.GetGlobalResourceObject( // propertyDefinition.ResourceFile, // propertyDefinition.RegexValidationErrorResourceKey); //if (o != null) //{ // regexValidator.ErrorMessage = o.ToString(); //} //else //{ // regexValidator.ErrorMessage = propertyDefinition.RegexValidationErrorResourceKey; //} } regexValidator.Display = ValidatorDisplay.Dynamic; parentControl.Controls.Add(regexValidator); } break; } } Literal rowCloseTag = new Literal(); rowCloseTag.Text = "</div>"; parentControl.Controls.Add(rowCloseTag); }