Save and close button

This forum is where we'll mirror posts that are of value to the community so they may be more easily found.
Post Reply
User avatar
Hostmaster
Commander (CMDR)
Commander (CMDR)
Posts: 126
Joined: Fri Jan 04, 2008 3:30 pm
Location: Melbourne Fl
Contact:

Save and close button

Post by Hostmaster » Thu Feb 21, 2008 8:16 am

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.

User avatar
m_plugables
Commander (CMDR)
Commander (CMDR)
Posts: 149
Joined: Tue Mar 11, 2008 12:44 am
Contact:

Save And Close Button

Post by m_plugables » Wed Mar 19, 2008 12:16 am

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" />
Last edited by m_plugables on Wed Mar 19, 2008 7:46 am, edited 1 time in total.

crazyjoe
Commander (CMDR)
Commander (CMDR)
Posts: 172
Joined: Mon Apr 26, 2010 2:20 pm

Re: Save and close button

Post by crazyjoe » Thu Sep 08, 2011 3:15 pm

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.
Crazy Joe Sadloski
Webmaster
Hot Leathers Inc.
http://www.hotleathers.com

Post Reply