Is there a way in the server side .NET code of a custom built web part to detect and use the properties of the page the web part will be deployed on.

So page library has custom column (property) "x" In web part want to use the value of column "x" i.e. "if x = 2 then...."

or failing that is there a way to detect the name of the page in the server side code of the web part so that I can use CAML to query the page library and get the SPListItem for that page and get the properties that way.

I know I can add a custom web part property to the tool pane and have the user just input the name of the page but I'd rather save my users having to do that.

1 Answer 1


Below snippet can give you the current URL


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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