.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Is it possible to use SPItemEventReceiver and SPFeatureReceiver together

Posted By:      Posted Date: September 14, 2010    Points: 0   Category :SharePoint
Hi, I have a class which is inherting the SPItemEventReceiver. I would like to use  the SPFeatureReceiver class with the same class file. Is it possible to use both the SPItemEventReceiver class and SPFeatureReceiver class in the same class file. I have now used: [CODE] class Program : SPItemEventReceiver [/CODE] Thank you

View Complete Post

More Related Resource Links

SPFeatureReceiver: Creating report viewer web part programmatically


I have a feature that adds a report viewer web part (SP integrated mode) into the newly created site page.

Problem: The feature activates without any problem through the UI, but I cannot activate it through STSADM (which will be the case when going to production).

Here is my code block that adds the web part to the page. This code block exists in FeatureActivated:

Assembly currentAssembly = Assembly.GetExecutingAssembly();
string dwpStr = string.Empty;

    using (Stream resourceStream = currentAssembly.GetManifestResourceStream("Report.dwp"))
        using (StreamReader sr = new StreamReader(resourceStream))
            dwpStr = sr.ReadToEnd();
            dwpStr = string.Format(dwpStr, web.Url);

    using (StringReader sr = new StringReader(dwpStr))
        string err = string.Empty;
        System.Web.UI.WebControls.WebParts.WebPart wp = wpMan.ImportWebPart((XmlReader.Create(sr as TextReader)), out err); //Exception thrown from this line
        wpMan.AddWebPart(wp, "HeaderZone", 0);
catch (Exception ex)
    //Log errors
Report.dwp is as follows:
<?xml version="1.0" encoding="utf-8"?>
<WebPart xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance&q

SPItemEventReceiver, properties.Cancel not working


I'm attempting to do some custom validation (which should be REALLY easy, but apparently is not).  I cannot use a column-level validation since I need to reference mulitple columns and I cannot do the List-level validation since I need to do multiple tests and the validation for the entire List only handles one test.

So I thought I'd try to capture the "ing" events for the list (Adding, Updating) and see if the old aspx standby of "e.cancel", etc. would work.  From what I found it should, sort of.  I've seen blogs that say I can do the following (My actual code):

      public override void ItemUpdating(SPItemEventProperties properties)

           DateTime sd = Convert.ToDateTime(properties.AfterProperties["StartDate"].ToString());
           DateTime ed = Convert.ToDateTime(properties.AfterProperties["_EndDate"].ToString());

           if (sd.Date >= ed.Date)

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend