ASPX templates
Version 5.x > ASPX templates > Setting webpart property View modes: 
User avatar
Member
Member
ryans-tushaus - 12/2/2010 11:59:43 PM
   
Setting webpart property
I have a tree view control on an ASPX template page. I am trying to set the Path property in code when the page loads. This should be straightforward but it is not working; the Path property is not being updated and the tree view is therefore not using the desired root node. My code is as follows:

protected void Page_Load(object sender, EventArgs e)
{
this.cmstreeview1.Path = "/CustomersOnly/%/";
this.cmstreeview1.ReloadData();
}

User avatar
Kentico Consulting
Kentico Consulting
kentico_mirekr - 12/3/2010 2:00:43 AM
   
RE:Setting webpart property
Hi,

I can see that your Path value is incorrect. Could you please use some valid expression?

Example:

this.cmstreeview1.Path = "/CustomersOnly/%";


Moreover, are you using CMSTreeView as control or are you registering this control in your ASPX page template as web part with path to CMSTreeView web part (~/CMSWebParts/Navigation/cmstreeview.ascx)?

If you are using CMSTreeView as control, please reload the control with true parameter.
Example:

this.cmstreeview1.Path = "/CustomersOnly/%";
this.cmstreeview1.ReloadData(true);


I hope this will help you.

Best regards,
Miro Remias.

User avatar
Member
Member
ryans-tushaus - 12/8/2010 2:55:47 PM
   
RE:Setting webpart property
I am using the tree view web part. I set the properties as you suggested but it is still displaying the root node starting at the root of the website rather than the path that I specified.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 12/8/2010 3:35:20 PM
   
RE:Setting webpart property
Hi,

could you please compare your code with following (the webpart displays only documents from /Product/% section and the Path property is defined in the code behind):


<%@ Register Src="~/CMSWebParts/Navigation/cmstreeview.ascx" TagName="cmstreeview"
TagPrefix="uc8" %>

<cms:CMSTreeView ID="CMSTreeView2" ShowLines="true" ExpandCurrentPath="true" runat="server" ExpandImageToolTip="Expand" HiglightSelectedItem="true" CollapseImageToolTip="Collapse" SelectedItemStyle="background-color:#000055; color:#ffffff; padding-left: 1px; padding-right: 5px; text-decoration: none;" DisplayDocumentTypeImages="false" Path="/Products/%" ClassNames="cms.cellphone;cms.laptop;CMS.MenuItem;cms.pda;CMS.Product;" Target="_blank" ExpandAllOnStartup="true" HideRootNode="false" EnableViewState="false">
</cms:CMSTreeView>



code behind:



protected void Page_Load(object sender, EventArgs e)
{
CMSTreeView2.Path = "/Products/%";
CMSTreeView2.ReloadData(true);
}


Best regards,
Ivana Tomanickova

User avatar
Member
Member
ryans-tushaus - 12/8/2010 3:55:37 PM
   
RE:Setting webpart property
Thanks to both of you for your help. I was not able to get it working with the web part but was able to get it working with the control. ReloadData() does not accept a parameter for the webpart but I was able to pass a parameter for the control and force a reload.