Pages

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

2 comments:

  1. Hi Disha shah Iam new to software field I dont have enough knowledge on .net so can i go for hsarepoint or else i should have commanding knowledge in .net to getinto sharepoint .Im in confusion please suggest with this regards ..Thanks in advance..

    ReplyDelete
    Replies
    1. Hi Vikky

      I prefer first you should learn some basic concepts of .NET which helps you in learning SharePoint Like Webservices, OOPS concepts and website concepts etc.

      Then Learn the SharePoint , anyone can learn anything at any age if they have wish and willpower to do that.

      Disha Shah

      Delete