SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am following this link on how to create metadata navigation :-

so I added the references for the navigation , but now I want to know where I should add the following code:-

public class CustomWikiPageBase : PublishingLayoutPage
    protected override void OnInit(EventArgs e)
        if (!String.IsNullOrEmpty(Request.QueryString["TreeField"]) 
            && !String.IsNullOrEmpty(Request.QueryString["TreeValue"]))
        else if (!String.IsNullOrEmpty(Request.QueryString["TreeField"]))

Is there a way to add this code on a web part? If yes then what type of web part it should be ? and could I do this using SharePoint designer?


share|improve this question
up vote 1 down vote accepted

You can do this in a regular web part (don't need a visual web part). Just put the OnInit override method in the web part code.

share|improve this answer
i tried overriding the Oninit method , but it raised the following error inside Visual Studio :- Error 2 The name 'Request' does not exist in the current context. – John Peter May 28 '13 at 21:46
You can use HttpContext.Current.Request and HttpContext.Current.Response. – John Chapman May 29 '13 at 14:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.