0

I am making a visual web part for SP2010, and the webpart hides shows content depending on if there was a postback or not. However the only exception to this, is the postback of exiting the page edit mode.

Is there a c# code that I can use to detect when the user has just checked in, or published the page during the postback? Basically a way to get the boolean value on page load that is true when the user checked in or published.

Does anyone know? Thanks.

1 Answer 1

2

What is the real objective? As far as I know there is no easy way of, from a webpart knowing if the page (list item) has just been published or checked in.

You can use the following code to check if the page is in display or edit mode and take some action:

if (Microsoft.SharePoint.SPContext.Current.FormContext.FormMode == SPControlMode.Display)
  {
   // your code to support display mode
  }
  else //     Microsoft.SharePoint.SPContext.Current.FormContext.FormMode = SPControlMode.Edit
  {
   // your code to support edit mode
  }

Not sure if this is helpful in your scenario though. Maybe you can save the last value and compare it to the current value on a post back to see if the user has just left edit mode!

2
  • I did some research, and saw this page: ryanfarley.com/blog/archive/2005/03/11/1886.aspx. I am thinking that if I can get the name of the postback status, and see what it is for "clicked checked in or publish". Then I might be able to tell.
    – omega
    Commented Jul 15, 2013 at 19:28
  • It seems by using Page.Request.Params.Get("__EVENTTARGET");, the value from that is ctl00$WebPartAdder when u added the webpart, and aspnetForm when you click close, and empty string when its a postback from your own control.
    – omega
    Commented Jul 15, 2013 at 19:44

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.