Page 1 of 1

Save and close button

Posted: Thu Feb 21, 2008 8:16 am
by Hostmaster
In the Manage Content and Layout (Scriptlets) area, please add a Save and close button, just like the Product page.

When working on the layout and style in the scripts I have found That I continually return to tweak the same page as I test the changes I intend to make. And this change would and will save time, each and every time.

Additionally the themes file manager when working in the style Sheets always take you back to the top of the file when pressing save, I have gotten into the habit of Adding a comment on the area I am working in so a quick fine will bring me back to where I was. If this could be changed I think it would be helpful.

Save And Close Button

Posted: Wed Mar 19, 2008 12:16 am
by m_plugables
Edit the Admin/Website/Scriptlets/EditScriptlet.aspx page.

Add a new function Save and put all the SaveButton_Click function code in it with two small modifications

Code: Select all

private bool Save() 
{
      if (Page.IsValid)
        {
            //IF NAME HAS CHANGED WE MUST VERIFY IT IS NOT A DUPLICATE
            string updatedIdentifier = Identifier.Text.Trim();
            bool validIdentifier = true;
            if (_Scriptlet.Identifier.ToLowerInvariant() != updatedIdentifier.ToLowerInvariant())
            {
                Scriptlet scriptlet = ScriptletDataSource.Load(updatedIdentifier, _ScriptletType, BitFieldState.True, false);
                if (scriptlet != null)
                {
                    CustomValidator uniqueValidator = new CustomValidator();
                    uniqueValidator.ControlToValidate = "Identifier";
                    uniqueValidator.IsValid = false;
                    uniqueValidator.Text = "*";
                    uniqueValidator.ErrorMessage = "A scriptlet with that name already exists. Name must be unique.";
                    IdentifierUnique.Controls.Add(uniqueValidator);
                    validIdentifier = false;
                }
            }
            if (validIdentifier)
            {
                _Scriptlet.Identifier = Identifier.Text.Trim(" \r\n\t".ToCharArray());
                _Scriptlet.Description = Description.Text.Trim(" \r\n\t".ToCharArray());
                _Scriptlet.HeaderData = HeaderData.Text.Trim(" \r\n\t".ToCharArray());
                _Scriptlet.ScriptletData = ScriptletData.Text.Trim(" \r\n\t".ToCharArray());
                if (_Scriptlet.IsDirty) _Scriptlet.IsCustom = true;
                _Scriptlet.Save();
            }
            return validIdentifier;
        }
        return false;
}
change the protected void SaveButton_Click(object sender, EventArgs e) function to look like

Code: Select all

protected void SaveButton_Click(object sender, EventArgs e)
{
      Save();
}
Add a new function

Code: Select all

protected void SaveCloseButton_Click(object sender, EventArgs e)
{
    if (Save())
       RedirectMe();
}
And now we have to add a "Save And Close" button to the page for
this locate the following line of code on the page

Code: Select all

<asp:Button ID="SaveButton" runat="server" Text="Save" OnClick="SaveButton_Click" />
just make a copy of the line of code and make it look like

Code: Select all

<asp:Button ID="SaveCloseButton" runat="server" Text="Save And Close" OnClick="SaveCloseButton_Click" />

Re: Save and close button

Posted: Thu Sep 08, 2011 3:15 pm
by crazyjoe
I am so glad I found this post! Thank you very much, this modification will save me tons of annoying back and forth clicking and testing.