Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I'm extremly new with Sharepoint 2010. In my masterpage, I display a list of news. I'd like to create a permanant "Add news" at the bottom of the list (programmatically) but I can't find the ListId. I've seen on the web I have to use {ListId} token, but I can only do this in XSLT files.

Here is a piece of my masterpage's code :

<a class="ms-addnew" id="idHomePageNewAnnouncement" href="http://thisWebsite/_layouts/listform.aspx?PageType=8&amp;ListId={ListId}&amp;RootFolder=" onclick="javascript:NewItem2(event, &quot;http://thisWebsite/_layouts/listform.aspx?PageType=8&amp;ListId={ListId}&amp;RootFolder=&quot;);javascript:return false;" target="_self">Add news</a>

I tried to replace ListId by ListID, List, $List etc... the generated link is always the same :

http://thisWebsite/_layouts/listform.aspx?PageType=8&ListId={ListId}&RootFolder=

Obviously, it didn't work because {ListId} is not replaced by its value...

Can somebody tell me where I'm wrong ? Thanks in advance :-)

share|improve this question
add comment

1 Answer

up vote 0 down vote accepted

You can build a URL using the name of the list for your Add News link like so:

http://YourSharePointSite/Lists/YourNewsListName/NewForm.aspx
share|improve this answer
    
Richard, I tried your solution, but I'm facing with this issue : When I click on "List", then "News" (the name of my list), an "Add news" is generated by Sharepoint, and it works. I looked at the GUID and try to write it directly in my code using List={GUID}. But when I re-deploy my website, my "Add news" still doesn't work inspite of the "good" GUID. When I re-reclic on "List", then "News"... The GUID of the "Add news" generated by Sharepoint has changed !! The only working link is the one generated by SP, and it changes each time I deploy ! I don't really understand why ... ? –  AlexB Apr 3 '13 at 16:00
    
How have you created the web site? Is it in visual studio or did you create a template through the UI? –  Richard Apr 3 '13 at 16:03
    
I created it with VS 2010. –  AlexB Apr 4 '13 at 6:56
    
Every time you deploy your solution, a new GUID will be generated for your list, unless you add a List Instance to the project. You can also create a url using the name of the list. I have modified the answer to reflect that. –  Richard Apr 4 '13 at 14:10
    
Your modified answer perfectly works ! It was so easy... Thank you very much RIchard !! –  AlexB Apr 4 '13 at 14:22
add comment

Your Answer

 
discard

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.