Question

I have some strange issue with server object model... I am creating timerjob, its has to just run item.update() function and rest of work is done by event receiver.

server url - demo2010a:2010

sitecolletion url - http://www.contoso.com/sites/test/

list url - http://www.contoso.com/sites/test/Lists/Zadania%20naprawcze%20t/

the problem is in:

        SPSite site = new SPSite("http://www.contoso.com/sites/test/");
        SPWeb web = site.OpenWeb("sites/test");

        SPList ldk_List = web.GetList("http://www.contoso.com/sites/test/Lists/Zadania naprawcze t"); //this is working fine ! but i cant use absolute URL !!!
        SPListItem item = ldk_List.GetItemById(5);
        item["Title"] = "testestestestes";
        item.Update();

this is my "Test" code. List name is "Zadania Naprawcze -t" in url its look strange but it is working with http://www.contoso.com/sites/test/Lists/Zadania naprawcze t i want something like : web.GetList("/sites/Zadania Naprawcze -t"); or something i tried to cut the - etc. could someone tell me what should to do? All the code is running as Timer Job.

Was it helpful?

Solution

Your question isn't perfectly clear. "Lists/Zadania naprawcze t" works and is the URL of the list. "/Lists/Zadania%20naprawcze%20t/" is the same thing just encoded (%20 = space). Now you're asking about -t, where do you get the - from? There is a difference between list title and list url, you know that right? The GetList method requires you to provide the List URL, there also is the SPListCollection.TryGetList method which you could provide with the title of the list (web.lists.TryGetList()).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top