sayali
sayali

Reputation: 255

API changes in kentico 9

I have upgraded my Kentico project from 8.2 to 9. In my custom code I am getting the following error:

'SaveAction' does not contain a constructor that takes 1 arguments

This is my code:

CurrentMaster.HeaderActions.AddAction(new SaveAction(this));

API changes documentation suggests to change it to:

CurrentMaster.HeaderActions.AddAction(new SaveAction());

Is this a correct implementation?

Upvotes: 0

Views: 112

Answers (1)

rocky
rocky

Reputation: 7696

Yes, this is a correct way to use it. You'll probably also want to implement the behavior of the save action:

HeaderActions.ActionPerformed += HeaderActions_ActionPerformed;

private void HeaderActions_ActionPerformed(object sender, CommandEventArgs e)
{
    switch (e.CommandName)
    {
        // Save object
        case ComponentEvents.SAVE:
          // Your code here
          break;
    }
}

Have a look at CMS\CMSModules\Ecommerce\Pages\Tools\Products\Variant_New.aspx.cs for instance.

Upvotes: 1

Related Questions