.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

Feature Event has 'null' objects

Posted By:      Posted Date: April 10, 2011    Points: 0   Category :C#
public class Feature1EventReceiver : SPFeatureReceiver { 
 public override void FeatureInstalled(SPFeatureReceiverProperties properties) 
 string sContextNull = (SPContext.Current == null) ? "Context is NULL" : "Context is OK";
 string sFeatureNull = (properties.Feature == null) ? "Feature is NULL" : "Feature is OK";

 // Some code here 

The feature has successfully installed (without error in logs).
My problem is that sContextNull always returns "Context is NULL". And sFeatureNull always returns "Feature is NULL" too.  
Is there a way to get not null values of SPContext.Current and prop

View Complete Post

More Related Resource Links

How to check for null/empty strings on dynamic objects?


What is the proper way to check for null or empty strings on dynamic objects? This is the only solution I've found so far:

if (admin.PasswordHash.GetType() == typeof(DBNull) || admin.PasswordHash == string.Empty)

If the field is null, the object returned is DBNull.Value, but if the field is empty string, it's return as a System.String object. This makes it impossible to do regular "admin.PasswordHash == DBNull.Value" check, as that will fail whenever the field has been set to empty string. Is my example the right (and only) way to go?

Why feature with event receiver doesn't activate properly after site provisioning?



I have defined feature with event receivers for my document library and for users List .

I try to activate my feature in onet.xml in section <WebFeatures>. After provisioning a new site from onet.xml  all work fine and my feature is shown as activated, but event receivers doesn't fire. It fires only after reactivating my feature (deactivate, then activate it again). But I need my feature works immediately after site provisioning without deactivating and activating it again. Who knows how to solve this problem?

part of ONET.xml



        <Feature ID="00BFEA71-4EA5-48D4-A4AD-7EA5C011ABE5"/>

        <!-- TeamCollab Feature -->

        <Feature ID="F41CC668-37E5-4743-B4A8-74D1DB3FD8A4"/>

        <!-- MobilityRedirect -->

        <!--My EventReceivers Feature-->

        <Feature ID ="41178843-A6A4-47c7-9EF9-B8A432E02B88"></Feature>





Feature Stapling and the FeatureActivated Event in Windows SharePoint Services 3.0

You can attach (or staple) a SharePoint Feature to a site definition without modifying the original site definition. Learn about issues related to using Feature Stapling with the SPFeatureReceiver.FeatureActivated event.

Gridview RowCommand Event returning null values

HiI'm trying to retreive values entered by users in the textboxes in the footer of the gridview and insert these values into another sql table.My code is as follows :-protected void GridView2_RowCommand(object sender, GridViewCommandEventArgs e)    {       if(e.CommandName.Equals("addnew"))       {                       TextBox t1 = (TextBox)GridView2.FooterRow.FindControl("tfrm");            string frm = t1.Text;            TextBox t2 = (TextBox)GridView2.FooterRow.FindControl("tsub");            string sub = t2.Text;            string cmd = "insert into suggestions values('" + frm + "','" + sub + "','c','c')";            con.Open();            SqlCommand com = new SqlCommand(cmd,con);            int a = com.ExecuteNonQuery();&n

Copying a Source DB objects into Destination DB with CDC feature...Please help

Hi,     I have a source database 'DB_Srce'. Now, my work is to create a package.If I run the package for the first time,it loads all the objects (tables/SPs/ and etc)  into the DB_Destn databse and the subsequent runs (may be schedules time),it fetches only the modified records (inset/update/delete) to the destination database. I think it involves CDC feature. I am new to SSIS.Could you please help with the steps,please?

Running code after site definition site creation in a event receiver or feature receiver

Hi guys I've got a site definition which is pretty much based on STS.This is it's own sharepoint project. Let's call this project SiteDefProj. Next in another SharePoint project (same solution though). Let's call this CustomListProject. In this project I've got a feature which provisions a bunch of lists based on custom content types - this feature is a site scoped. Let's call this feature: CustomListInstances. I have added a feature receiver to this feature to execute some custom code on the lists themselves (under feature activated) In my ONET.XML (part of the SiteDefProj) I have CustomListInstances feature ID as part of my <sitefeatures>. When I do a create site I can actually step through the code and see it actually being executed but after the site is created the list instances are created but it's like the code never run or did anything. The weird part is that stepping through the code while creating a site collection using my SiteDefProj the code runs great with no errors. All lists are there and the code runs smooth. If I manually create a STS site and activate my feature everything works and the code does actually run and the effects are visible after the feature is created. Again I can actually step through it in debug. My suspicion is that there's some sort of a race condition in the CREATE SITE functionality where maybe the web or site collection hol

Custom Event Handler causes "Potentially excessive number of SPRequest objects".

I am getting the following in our custom event handler on our WSS 3.0 installation.  Potentially excessive number of SPRequest objects (9) currently unreleased on thread 10.  Ensure that this object or its parent (such as an SPWeb or SPSite) is being properly disposed. This object is holding on to a separate native heap. I know this is normally a performance issue due to incorrect coding technique, but I cannot figure out where my leak might be? Here is the code.         private const string _workflowName = "ROUTINGROUTER";         private const string _workflowName2 = "ROUTINGWORKFLOW";         private const string _currStateField = "CurrentState";         private const string _fieldName = "InProcess";         private const string _actionFieldName = "SourceAction";         private const string _triggerFieldValue = "FALSE";         private const string _actionTrigger = "RUN";         private const string _routingListName = "LIPList";         public override void ItemUpdated(SPIte

WorkFlow Event Reveiver parameter "properties.ActivationProperties" is null.

I have been trying to write the event receiver on completion of my out of box "Approval - Sharepoint 2010 workflow" set on a Site Page library. I need to update some column on completion of the workflow.

So for this I need is the list and listItem to which the workflow is attached and the column that I need to update. I understand I can get this using "properties.ActivationProperties" but what I get is null value for this. Can someone help me in this regard? I also tried reading the same in workflowStarted event but even there I get the value as null.

Page onload event override through Feature


I am trying to override the page OnLoad event through Feature. i am following this link. 



here is element file which i created.

<?xml version="1.0" encoding="utf-8" ?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">


Reporting service, subscription event always null


Hi All, i discover an issue for reporting subscription, since look like very ccommon but i still cant find a good solution, please help

SQL version: SQL version 2000

issue: I am trying to get a time subscription for a report to work. The SQL Agent
job is created, and runs successfully. The ReportServer.dbo.AddEvent sp is
run and add record to the "event" table in the ReportServer datanase, but
event appears to never be executed by the ReportServer. How do I verify that
the Report Server is actually polling this table to verify whether or not
there are events to run.


Using SharePoint Search feature in ASP.Net Application

Integrating ASP.Net application in to MOSS 2007 to utilize SharePoint Enterprise Search Feature can be done by using Business Data Search.

Radio Button Event

Here I have explained the events of radio button with javascript.
Let me explain the scenarion first,
We are having two radio button say radioobtn1 and radiobtn2. If I click on the button 1 then I need to show one DIVor FORM. same as when I click on radiobtn 2. I have given the code for the above scenarion.

how to impose javascript event processing?


If I have some form control like textbox and I want the event handler to be located in the html instead of at the server side, how to do that? Of course I can copy paste javascript code in the aspx file. But is it possible to do that using some object oriented approach (ie programmatically in the code behind)?


Need help with objects and arrays


I have an objuct that I declared like this:

    Class DailyStats
        Dim _day As String
        Dim _hour As String
        Dim _impressions As String
        Dim _clicks As String
        Property Day() As String
                Return _day
            End Get
            Set(ByVal value As String)
                _day = value
            End Set
        End Property
        Property Hour() As String
                Return _hour

Dropdown Event (Template Field)



I have grid view control that includes a dropdown control in a template field.

I wish to execute some code when the value is changed in the dropdown list.  Can't figure out how to capture this event though?

Any suggestions?

how to serialize objects ??


Is there any way or process to serialize the the objects?? i am trying to store the instance of few control in viewstate but it shows error msg that it is not a serialized object. should i perform some steps to serialize the objects ???

Users getting logged out because HttpContext.Current is null


We've  been trying to fix this one for a couple years, and I'm just out of ideas, so any help is really appreciated!

We've got a fairly large, complex web application that uses Forms Authentication to authenticate users.  Throughout the application we store and retrieve information about users in the Session object, and in some cases in cookies.  In a couple places we check for the existence of the context, and if it's null we send the user back to the login page to re-establish the session. 

Just a quick run-down of this web app: C#, .NET 3.5, IIS 6, ASP.NET State Service to manage session

As for the session timer, we use our own home-grown timer, which is basically a client-side timer, which is backed up by a check to the SQL database to see when their last activity was.  This seems to work well for us.  It's not perfect, but it allows us to notify the user before the session times out, and allows us to be certain we're not logging a user out before their 60 minutes of inactivity is up.

What's happening is that certain users are being logged out after just a few minutes.  We've eliminated the timer as a cause and believe what's happening is the HttpContext.Current is null, so the user is logged out.  We do not know why the HttpContext.Current is null, and I underst

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