Archive for the ‘QueryString’ Category


Below is the code to create a link in a page which includes some value from the querystring of the current page.

<script>
var qsParm = new Array();
function qs()
{
     var query = window.location.search.substring(1);
     var parms = query.split('&');
     for (var i=0; i<parms.length; i++)

    {
         var pos = parms[i].indexOf('=');
         if (pos > 0)

        {
             var key = parms[i].substring(0,pos);

             var val = parms[i].substring(pos+1);
             qsParm[key] = val;
        }
    }
}
qsParm['ID'] = null;
qs();
var addressTr= "Technical%20View.aspx?ID=" +  qsParm['ID'] ;
document.write('<a target="_self" href="' + addressTr + '">Technical View</a>');
</script>


Add System.Web namespace

public class MyEventHandler: SPItemEventReceiver
{
HttpContext current;

String requestNumber;
public MyEventHandler()
{
current = HttpContext.Current;
requestNumber=Convert.ToString(this.current.Request.QueryString[“reqno”]);
}
public override void ItemAdded(SPItemEventProperties properties)
{
// code  for event handler goes here

}

Since event handler methods doesn’t have access to the page object we cant access query string and Session values.
So you can use the current object to access the query string and Session values.