Scenario:
I wanted to get all the sub sites directly beneath the current site
Solution:
You can do this using Web Service call using Web.asmx
Code:
proxy.Webs ws = new proxy.Webs();
ws.Url = "http://localhost/_vti_bin/Webs.asmx";
ws.Credentials =System.Net.CredentialCache.DefaultCredentials;
System.Xml.XmlNode nd = ws.GetWebCollection();
XmlNodeList ndlist = nd.ChildNodes;
foreach (XmlNode xGet in ndlist){
string sWebTitle = xGet.Attributes["Title"].Value;
string sOneSubSite =xGet.Attributes["Url"].Value;
}
3 comments:
Where do i put that code??
Good question , but the reason I didn't specify exactly where to use it was , it can be used at multiple places
1. in a webpart
2. in a console application
3. in a timer job
4. in a window service and many more.. depending upon how you want to consume this information
How can I use this web service on a InfoPath form to display all the subsites Dynamically in a drop down list.
Post a Comment