I moved my implementation to use Master Pages now the CheckedNodes.Count is always 0.The code is below.
It worked fine when it was on the same page. I don't have RadFormDecorator.
RadTreeView RadTreeView1 = (RadTreeView)Master.FindControl ("RadTreeView1");
checkedCategories = RadTreeView1.CheckedNodes.Count;
2 Answers, 1 is accepted
0
Hi Tony,
We are not exactly sure what might cause the issue. Could you please open a support ticket and send us a sample project which demonstrates the exact problem to examine it locally?
All the best,
Plamen Zdravkov
the Telerik team
We are not exactly sure what might cause the issue. Could you please open a support ticket and send us a sample project which demonstrates the exact problem to examine it locally?
All the best,
Plamen Zdravkov
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Tonyz289
Top achievements
Rank 1
answered on 03 Nov 2011, 08:46 PM
I solved it. The problem was that I was initiating the call to do the count from a RadButtonBar on the MasterPage. It was Redirecting to the page that had the routine on it when I should have been using reflection to execute the routine. Below is the working example that solves the problem.
<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
title
></
title
>
<
asp:ContentPlaceHolder
ID
=
"head"
runat
=
"server"
>
</
asp:ContentPlaceHolder
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
div
>
<
telerik:RadToolBar
ID
=
"RadToolBar1"
runat
=
"server"
Height
=
"35px"
OnButtonClick
=
"RadToolBar1_ButtonClick"
>
<
Items
>
<
telerik:RadToolBarButton
runat
=
"server"
ImageUrl
=
"~/images/icon_link.gif"
ToolTip
=
"Link Assets"
Value
=
"linkassets"
>
</
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
<
telerik:RadTreeView
ID
=
"RadTreeView1"
runat
=
"server"
DataFieldID
=
"ProductID"
DataSourceID
=
"SqlDataSource1"
DataTextField
=
"ProductName"
DataValueField
=
"ProductName"
CheckBoxes
=
"True"
>
</
telerik:RadTreeView
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:NorthwindConnection %>"
SelectCommand="SELECT TOP 10 [ProductID], [ProductName] FROM [Alphabetical list of products]">
</
asp:SqlDataSource
>
<
asp:ContentPlaceHolder
ID
=
"ContentPlaceHolder1"
runat
=
"server"
>
</
asp:ContentPlaceHolder
>
</
div
>
</
form
>
</
body
>
</
html
>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class MasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void RadToolBar1_ButtonClick (object sender, Telerik.Web.UI.RadToolBarEventArgs e)
{
if (Page.AppRelativeVirtualPath.ToLower() == "~/default.aspx")
callContentFunction ("linkassets");
else
Response.Redirect ("Default.aspx?action=linkassets");
}
private object callContentFunction (string methodName, params object[] parameters)
{
Type contentType = this.Page.GetType ();
System.Reflection.MethodInfo mi = contentType.GetMethod (methodName);
if (mi == null) return null;
return mi.Invoke (this.Page, parameters);
}
}
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="Default"
MasterPageFile="~/MasterPage.Master" %>
<%@ MasterType VirtualPath="~/MasterPage.Master" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
runat
=
"Server"
>
<
telerik:RadButton
ID
=
"RadButton1"
runat
=
"server"
Text
=
"RadButton"
OnClick
=
"RadButton1_Click"
>
</
telerik:RadButton
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
Label
=
"Count: "
>
</
telerik:RadTextBox
>
</
asp:Content
>
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
public partial class Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
String action = Request.QueryString["action"];
if (action != null)
{
if (action.ToLower () == "linkassets")
linkassets ();
}
}
}
protected void RadButton1_Click (object sender, EventArgs e)
{
linkassets ();
}
public void linkassets ()
{
RadTreeView RadTreeView1 = (RadTreeView)Master.FindControl ("RadTreeView1");
Int32 checkedCategories = RadTreeView1.CheckedNodes.Count;
RadTextBox1.Text = checkedCategories.ToString ();
}
}