0

On my publishing pages i have a custom user control that contains a SAVE button when the page is in Edit Mode. On click event of that button i do:

this.page.Update();
this.page.CheckIn(DateTime.Now.ToString() + " page saved");
this.page.Publish(DateTime.Now.ToString() + " page published");
Response.Redirect(SPContext.Current.Web.Url + "/" + this.page.Url);

But the contents are not being updated? What is wrong with it?

1 Answer 1

1

how about trying this code?

Microsoft.SharePoint.WebControls.SaveButton.SaveItem(SPContext.Current, false, "Time Saved = " + DateTime.Now);

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.webcontrols.savebutton.saveitem.aspx

also have the update at the bottom not top of the code stack, you could try somthing like this ;) :

http://praveenbattula.blogspot.co.uk/2011/08/set-page-layout-programatically-for.html

hope it helps :)

4
  • thanks, i will try it when i go back to work tomorrow. but what is wrong with my way of doing save?
    – ozdogan
    Nov 27, 2012 at 17:41
  • 1
    i think the issue is when you do it manually, by that i mean when you do it yourself on the page you check out the page then make the changes, you then save the page and the check in the page. The last step is to publish the page and update :)
    – Ali Jafer
    Nov 27, 2012 at 22:13
  • Hello it worked. Actually what to do after SaveButton.SaveItem() ? only page.Publish() ?
    – ozdogan
    Nov 28, 2012 at 7:59
  • 1
    yes, do the checkin, then save then publish
    – Ali Jafer
    Nov 28, 2012 at 8:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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