I've created a new feature for a specific list. This new feature will show a button in the EditToolBar of a list page when editing. After clicking that new button, it should take you to another page and display some data. I already added the xml files and also a .aspx files to the SharePoint folder and also installed the feature and activated it for that site.

Now, I can't get the current list and current item in my new aspx page by using SPContext.Current.List or SPContext.Current.Item. It gives an error.

Any ideas?


Pass through the List and Item IDs in the querystring?

The Context is lost in an application page I believe.

| improve this answer | |
  • Thanks for your quick answer, How can I do that from a feature? I mean, How can I get the values of this in the feature xml file. – Carlos Blanco Sep 23 '10 at 18:10
  • How are you displaying the button in the toolbar in the first place? – James Love Sep 23 '10 at 18:19
  • Just by adding the line Location="EditFormToolbar" in the elements.xml of the feature. – Carlos Blanco Sep 23 '10 at 18:28
  • Ah, understood, and you have a separate link which links to your application page in the elements.xml, also. I think the easiest way to be able to dynamically add stuff to the querystring is to use a usercontrol for the button on the toolbar. – James Love Sep 23 '10 at 18:33
  • I found that adding this to the element URL of the xml file ?ItemId={ItemId}&ListId={ListId} that information is added to the URL. Thanks James – Carlos Blanco Sep 23 '10 at 18:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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