zaterdag 5 november 2011

Get ContentTypes of a List


Get available ContentTypes on a List using the SharePoint Webservice Lists.asmx .  

    private void GetListsContentTypes(string myurl, string mylist, ArrayList myAlist)
    {
        SetStatus("Initialize webservice...");
        myAlist.Clear();
        WS_Lists.Lists lists = new WS_Lists.Lists();
        if (chk_DefaultLoggin.Checked)
            lists.Credentials = System.Net.CredentialCache.DefaultCredentials;
        else
        {
            lists.PreAuthenticate = true;
            lists.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
        }
        lists.Url = myurl + @"/_vti_bin/lists.asmx";
        try
        {
            this.SetStatus("getting contenttypes for list " + mylist);
            XmlNode myNode = lists.GetListContentTypes(mylist, "0x01");
            XmlNodeList nodes = myNode.SelectNodes("*");
            foreach (XmlNode node in nodes)
            {
                myAlist.Add(node.Attributes["Name"].Value);
            }
        }
        catch (Exception exception1)
        {
            MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
            this.SetStatus("Error loading list info");
        }
        finally
        {
            lists.Dispose();
        }
    }

 

Geen opmerkingen:

Een reactie posten