I want to respond to the insertion of data into a Sharepoint list (which will be done from the client/JavaScript (*.asxc file) in the code-behind/C#.
Is there a way to do that? Can I hook up an "OnListUpdated" handler in the Sharepoint Web Part's code-behind (*.ascx.cs) file?
I want to let the user just select one button, which will populate the list (from the client) and then immediately thereafter generate a PDF file (from the server).
I've got the following code:
namespace PostTravelWizard.PostTravelItemEventReceiver
{
public class PostTravelItemEventReceiver : SPItemEventReceiver
{
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
// TODO: Is this all that is needed?
PostTravelWizardWebPartUserControl.GeneratePDF();
}
public override void ContextEvent(SPItemEventProperties properties)
{
base.ContextEvent(properties);
// TODO: What "context event" occurs here? To what event should I respond?
}
}
}
...but I don't want to respond to every insert into the list; I only want to respond to the last one - when the updating is complete. But how I know when that is, I don't know. Will I have to put a "bogus" entry with a value like "that's all, folks!", look for that value, and then go from there, or is there a more sensible/less kludgy way of indicating/deciphering when it's done?
You can create an event receiver on the list and add ItemAdded or ItemUpdating or ItemUpdated events to that as per your requirement. From there you can notify the user after successful completion of an operation and then you can continue on the task of generating a pdf from the data in a list.