Search This Blog

Thursday, March 12, 2015

Get Value of QueryString from SharePoint Event Receiver



From SharePoint Event Receivers how could we get the value which has been passed from querystring? 
How can we achieve this? Here is the sample of code.
public class AddDataSPItemEventReceiver
    {
        System.Web.HttpContext httpContext = null;

        /// <summary>
        /// An item was added.
        /// </summary>
        public AddData ():base()
         {
                 //get the httpContext in contsructor, we won't get
                 //this outside of this constructor
             try
             {

                 httpContext = System.Web.HttpContext.Current;
             }
             catch (Exception Ex)
             {
             }
        }

public override void ItemAdding(SPItemEventProperties properties)
        {
                if (httpContext != null)
                {
                    if (httpContext.Request.QueryString["Data"] != null)
                    {
                                                String strData= httpContext.Request.QueryString["Data "].ToString();
}

                }
            }
}

No comments:

Post a Comment