1

I have a custom field type in Sitecore 8.

I use the Context.ClientPage.SendMessage to call the contenteditor:save command. This works, but forces the page to reload producing a warning dialogue to pop up. I actually only want the Save button to be enabled, so just need the page to know the state has changed.

This is my current code:

protected void Run(ClientPipelineArgs args)
{
    Assert.ArgumentNotNull((object) args, "args");

    if (args.IsPostBack)
    {
        Context.ClientPage.SendMessage(this, "contenteditor:save");
        return;
    }

    var urlString = new UrlString(args.Parameters["url"]);
    Context.ClientPage.ClientResponse.ShowModalDialog(urlString.ToString(), "700", "510", "", true);
    args.WaitForPostBack();
}
2

This should solve your problem:

Sitecore.Context.ClientPage.Modified = true;
0
2

To notify the Sitecore Client about changes in a custom field you have to call/override SetModified:

protected override void SetModified()
{
    base.SetModified();
    if (base.TrackModified)
    {
        Sitecore.Context.ClientPage.Modified = true;
    }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.