|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
Note: This is an unedited contribution. If this article is inappropriate,
needs attention or copies someone else's work without reference then please
Report This Article
IntroductionThis is my second release as a development cycle of AJAX Connectable webpart.While doing some R&D, I found that RowConsumer and Provider interface, ICellConsumer and ICellProvider interfaces are more effective when we are writing the connectable web part in AJAX framework. BackgroundThis is my second article so for more deep insight of AJAXConnectableWebPart, check out my previous article. AjaxConnectableWebPart_V1.0.0.0 Using the codeAll of first we need to derive our webpart from ICellProvider interface. ///There are some Event required by ICellProvider: //Events required by ICellProvider public event CellProviderInitEventHandler CellProviderInit; public event CellReadyEventHandler CellReady;
///
We are fetching the sub-sites at run time, when user expand the tree node.So I have written a recursive method, which will take care of filling the treeview at run time.
public void CreateTreeOnExpandNode(string URL, TreeNode nodeExpanded)
{
try
{
SPSite site = new SPSite(URL);
SPWeb web = null;
if (site.Url == URL)
{
web = site.OpenWeb();
}
else
{
URL = URL.Replace(site.Url, "");
if (site.ServerRelativeUrl != "/") URL = site.ServerRelativeUrl + URL;
web = site.OpenWeb(URL);
}
foreach (SPWeb web1 in web.Webs)
{
TreeNode childnode = new TreeNode(web1.Url);
//GetChild(web1, childnode);
if (web1.Webs.Count > 0)
{
TreeNode emptyNode = new TreeNode();
childnode.ChildNodes.Add(emptyNode);
}
nodeExpanded.ChildNodes.Add(childnode);
}
}
catch (Exception ex)
{
Page.Response.Write(ex.Message);
}
}
Consumer Part:For creating the consumer part I have derived my control class from ICellConsumer Interface and rest of the things are pretty similar to the provider part. For getting data from Provider part: /// HistoryPrevious Version - AJAXConnectableWebPart_V1.0.0.0 Current Version - AJAXConnectableWebPart_V1.0.0.1 HAPPY SHAREPOINTING.......Cheers!!!
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||