Pages

Showing posts with label Get Value of QueryString from SharePoint Event Receiver. Show all posts
Showing posts with label Get Value of QueryString from SharePoint Event Receiver. Show all posts

Thursday, February 2, 2012

Get Value of QueryString from SharePoint Event Receiver

Hello Friends

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 AddData: SPItemEventReceiver
    {
        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();
}

                }
            }
}


Enjoy coding!!!
Disha Shah