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 have created list (say List1) on Central Administration Site. I would like to read the title value from that list programmatically. How can I do it? I don't want to hard code the URL of central administration site.

Also, in my code I have SPWebApplication object of Central Admin .Let me know if I can use it .

share|improve this question

1 Answer 1

up vote 2 down vote accepted

You can use your web application object in the function like below :

private string GetListTitle(SPWebApplication webApp)
    {
        //To ensure if your web application object hosts central admin
        if (webApp.IsAdministrationWebApplication)
        {
            SPList list = webApp.Sites[0].RootWeb.Lists["List1"];
            return list.Title;
        }
        return string.Empty;
    }
share|improve this answer

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.