How to change the properties/method of one web part from within another web part - Kentico

This tutorial is to show how to access the web part properties/method from another web part. This situation basically when you use a repeater name repeater1 and inside repeater transformation you call another User control/web part name repeater2. Every time you trigger an event on the repeater2(ie: click, change the value, etc), you want to refresh the repeater1 value. But you cannot access the properties/method directly.

Code Behind repeater / repeater1

Override OnInit Event
   protected override void OnInit(EventArgs e)  
{

RequestStockHelper.Add("repeater2", this);
base.OnInit(e);
}


Code Behind UserControl / repeater2

Called ReloadData() from another webpart.
   protected void LinkButton1_Click(object sender, EventArgs e)  
{

CMSAbstractWebPart webpart = RequestStockHelper.GetItem("repeater2") as CMSAbstractWebPart;
if (webpart != null)
{
webpart.OnContentLoaded();
}
}

Popular posts from this blog

How to create zip file to download in JSP- Servlet

How to create DataGrid or GridView in JSP - Servlet

Pinging in ASP.NET Example