Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

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 :)

share|improve this answer
    
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 '12 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 Sharepoint Nov 27 '12 at 22:13
    
Hello it worked. Actually what to do after SaveButton.SaveItem() ? only page.Publish() ? –  ozdogan Nov 28 '12 at 7:59
1  
yes, do the checkin, then save then publish –  ali Sharepoint Nov 28 '12 at 8:46

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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