Hellooooo!!!!!
Hope things are going great.
I am working on Item Updating event receiver for a custom list : listitem , afterproperties , beforeproperties , blah , blah, blah.. And I am on the last step, and it is to find whether attachment is associated with the current item..
Simple????!!!!! Lets see..
int attachmentcount1 = Convert.ToInt32(properties.BeforeProperties["Attachments"]);
int attachmentcoun2 = Convert.ToInt32(properties.ListItem["Attachments"]);
int attachmentcount3 = Convert.ToInt32(properties.AfterProperties["Attachments"]);
what I am getting, “0” on all the three variables..
So wat is the fix, to check for the “Attachments” in the “Synchronous” event..
public class MyEventReceiver : SPItemEventReceiver
{
HttpContext currentContext;
public MyEventReceiver()
{
currentContext = HttpContext.Current;
}
public override void ItemAdding(SPItemEventProperties properties)
{
if (currentContext != null)
{
if (currentContext.Request.Files.Count > 0)
{
// Thers are attachments
}
else
{
// no attachments
}
}
}
}
This works on the case of Item Adding also.. :D
See you again.. Cyaa...
Hope things are going great.
I am working on Item Updating event receiver for a custom list : listitem , afterproperties , beforeproperties , blah , blah, blah.. And I am on the last step, and it is to find whether attachment is associated with the current item..
Simple????!!!!! Lets see..
int attachmentcount1 = Convert.ToInt32(properties.BeforeProperties["Attachments"]);
int attachmentcoun2 = Convert.ToInt32(properties.ListItem["Attachments"]);
int attachmentcount3 = Convert.ToInt32(properties.AfterProperties["Attachments"]);
what I am getting, “0” on all the three variables..
So wat is the fix, to check for the “Attachments” in the “Synchronous” event..
public class MyEventReceiver : SPItemEventReceiver
{
HttpContext currentContext;
public MyEventReceiver()
{
currentContext = HttpContext.Current;
}
public override void ItemAdding(SPItemEventProperties properties)
{
if (currentContext != null)
{
if (currentContext.Request.Files.Count > 0)
{
// Thers are attachments
}
else
{
// no attachments
}
}
}
}
This works on the case of Item Adding also.. :D
See you again.. Cyaa...
No comments:
Post a Comment