/// <summary> /// Gets and bulk updates inline controls. Called when the "Get and bulk update controls" button is pressed. /// Expects the CreateInlineControl method to be run first. /// </summary> private bool GetAndBulkUpdateInlineControls() { // Prepare the parameters string where = "ControlName LIKE N'MyNewControl%'"; // Get the data DataSet controls = InlineControlInfoProvider.GetInlineControls(where, null); if (!DataHelper.DataSourceIsEmpty(controls)) { // Loop through the individual items foreach (DataRow controlDr in controls.Tables[0].Rows) { // Create object from DataRow InlineControlInfo modifyControl = new InlineControlInfo(controlDr); // Update the properties modifyControl.ControlDisplayName = modifyControl.ControlDisplayName.ToUpper(); // Save the changes InlineControlInfoProvider.SetInlineControlInfo(modifyControl); } return true; } return false; }
protected void btnOK_Click(object sender, EventArgs e) { string errorMessage = new Validator() .NotEmpty(txtControlDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage) .NotEmpty(txtControlName.Text.Trim(), rfvName.ErrorMessage) .IsCodeName(txtControlName.Text.Trim(), GetString("general.errorcodenameinidentificatorformat")) .Result; if ((string.IsNullOrEmpty(errorMessage)) && (!FileSystemSelector.IsValid())) { errorMessage = FileSystemSelector.ValidationError; } if (string.IsNullOrEmpty(errorMessage)) { // Get object InlineControlInfo inlineControlObj = InlineControlInfoProvider.GetInlineControlInfo(controlId); EditedObject = inlineControlObj; // Update properties inlineControlObj.ControlDescription = txtControlDescription.Text.Trim(); inlineControlObj.ControlDisplayName = txtControlDisplayName.Text.Trim(); inlineControlObj.ControlParameterName = txtControlParameterName.Text.Trim(); inlineControlObj.ControlName = txtControlName.Text.Trim(); inlineControlObj.ControlFileName = FileSystemSelector.Value.ToString().Trim(); inlineControlObj.ControlResourceID = ValidationHelper.GetInteger(drpModule.Value, 0); try { // Save changes InlineControlInfoProvider.SetInlineControlInfo(inlineControlObj); ShowInformation(GetString("general.changessaved")); // Refresh header with display name ScriptHelper.RefreshTabHeader(Page, null); } catch (Exception ex) { ShowError(ex.Message.Replace("%%name%%", txtControlName.Text)); } } else { ShowError(errorMessage); } }
/// <summary> /// Creates inline control. Called when the "Create control" button is pressed. /// </summary> private bool CreateInlineControl() { // Create new inline control object InlineControlInfo newControl = new InlineControlInfo(); // Set the properties newControl.ControlDisplayName = "My new control"; newControl.ControlName = "MyNewControl"; newControl.ControlFileName = "~/CMSModules/Polls/InlineControls/PollControl.ascx"; newControl.ControlParameterName = "Poll name"; newControl.ControlDescription = "My new inline control description"; // Save the inline control InlineControlInfoProvider.SetInlineControlInfo(newControl); return true; }
/// <summary> /// Gets and updates inline control. Called when the "Get and update control" button is pressed. /// Expects the CreateInlineControl method to be run first. /// </summary> private bool GetAndUpdateInlineControl() { // Get the inline control InlineControlInfo updateControl = InlineControlInfoProvider.GetInlineControlInfo("MyNewControl"); if (updateControl != null) { // Update the properties updateControl.ControlDisplayName = updateControl.ControlDisplayName.ToLower(); // Save the changes InlineControlInfoProvider.SetInlineControlInfo(updateControl); return true; } return false; }
/// <summary> /// Sets data to database. /// </summary> protected void btnOK_Click(object sender, EventArgs e) { // Validate inputs string errorMessage = new Validator().NotEmpty(txtControlDisplayName.Text.Trim(), rfvDisplayName.ErrorMessage) .NotEmpty(txtControlName.Text.Trim(), rfvName.ErrorMessage) .IsCodeName(txtControlName.Text.Trim(), GetString("general.errorcodenameinidentifierformat")).Result; if ((string.IsNullOrEmpty(errorMessage)) && (!FileSystemSelector.IsValid())) { errorMessage = FileSystemSelector.ValidationError; } if (string.IsNullOrEmpty(errorMessage)) { // Create new inline control object InlineControlInfo inlineControlObj = new InlineControlInfo(); inlineControlObj.ControlDescription = txtControlDescription.Text.Trim(); inlineControlObj.ControlDisplayName = txtControlDisplayName.Text.Trim(); inlineControlObj.ControlFileName = FileSystemSelector.Value.ToString().Trim(); inlineControlObj.ControlParameterName = txtControlParameterName.Text.Trim(); inlineControlObj.ControlName = txtControlName.Text.Trim(); try { // Create new inline control InlineControlInfoProvider.SetInlineControlInfo(inlineControlObj); if ((chkAssign.Visible) && (chkAssign.Checked) && (CMSContext.CurrentSite != null)) { // Add new control to the actual site InlineControlSiteInfoProvider.AddInlineControlToSite(inlineControlObj.ControlID, CMSContext.CurrentSiteID); } // Redirect to edit page URLHelper.Redirect("Frameset.aspx?inlinecontrolid=" + Convert.ToString(inlineControlObj.ControlID) + "&saved=1"); } catch (Exception ex) { ShowError(ex.Message.Replace("%%name%%", txtControlName.Text)); } } else { ShowError(errorMessage); } }