In this function fill's in a ArrayList with the list of Views defined on a Site
using the SharePoint Webservice Views.asmx .
private void GetNewListsViews(string myurl, string mylist, ArrayList myAlist)
{
SetStatus("Initialize webservice...");
myAlist.Clear();
WS_Views.Views views = new WS_Views.Views();
if (chk_DefaultLoggin.Checked)
views.Credentials = System.Net.CredentialCache.DefaultCredentials;
else
{
views.PreAuthenticate = true;
views.Credentials = new System.Net.NetworkCredential(txt_UserID.Text, txt_PassWord.Text, txt_domain.Text);
}
views.Url = myurl + @"/_vti_bin/Views.asmx";
try
{
this.SetStatus("getting views for list " + mylist);
XmlNode myNode = views.GetViewCollection(mylist);
XmlNodeList nodes = myNode.SelectNodes("*");
foreach (XmlNode node in nodes)
{
if (node.Attributes["DisplayName"].Value != "")
myAlist.Add(node.Attributes["DisplayName"].Value);
}
}
catch (Exception exception1)
{
MessageBox.Show(exception1.Message, "Error loading list info", MessageBoxButtons.OK);
this.SetStatus("Error loading list info");
}
finally
{
views.Dispose();
}
}
Geen opmerkingen:
Een reactie posten