The page has a panel bar which dynamically loads TreeViews as PanelItems. To prevent losing the trees during a postback, a custom control is loaded in the XmlHttpPanel. In order to get the correct control and pass all desired information, I need to access multiple custom attributes of the selected node. Any suggestions on how to either pass or access the selected node server side (from within the "XmlHttpPanel_ServiceRequest" without performing a postback?
Update to post: The trees are gone upon the service request as well and since the tree and nodes or not serializable the information cannot be stored in the viewstate either. What was the point of making a control that loses its contents upon a postback? Looks like the path will be to stuff everything into a long string for use as the "value" on the service call then parse out what's needed. For such an impressive toolset overall, seems like the PanelBar is a tad lacking. Unless of course, I missing the obvious which is always a possibility.
Below is an overly simplified view of what is being attempted.
<!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
>
<
telerik:RadScriptBlock
ID
=
"RadScriptBlock1"
runat
=
"server"
>
<
script
language
=
"javascript"
type
=
"text/javascript"
>
function NodeClicked(sender, args) {
var node = args.get_node();
var panel = $find("<%= RadXmlHttpPanel1.ClientID %>");
panel.set_value(node.get_text());
}
</
script
>
</
telerik:RadScriptBlock
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
>
</
telerik:RadScriptManager
>
<
table
>
<
tr
>
<
td
>
<
telerik:RadPanelBar
ID
=
"RadPanelBar1"
runat
=
"server"
>
</
telerik:RadPanelBar
>
</
td
>
<
td
>
<
telerik:RadXmlHttpPanel
ID
=
"RadXmlHttpPanel1"
runat
=
"server"
OnServiceRequest
=
"XmlHttpPanel_ServiceRequest"
>
</
telerik:RadXmlHttpPanel
>
</
td
>
</
tr
>
</
table
>
</
form
>
</
body
>
</
html
>
public
partial
class
Default : System.Web.UI.Page
{
protected
void
Page_Load(
object
sender, EventArgs e)
{
if
(!Page.IsPostBack)
LoadRootContent();
}
private
void
LoadRootContent()
{
RadPanelItem myPanelItem =
new
RadPanelItem(
"Item 1"
);
RadTreeView myTreeView =
new
RadTreeView();
myTreeView.OnClientNodeClicked =
"NodeClicked"
;
//Build a node
RadTreeNode node1 =
new
RadTreeNode(
"TreeNode 1"
);
node1.Category =
"Customers"
;
node1.Attributes.Add(
"CustomerID"
,
"123"
);
myTreeView.Nodes.Add(node1);
//Build another node
RadTreeNode node2 =
new
RadTreeNode(
"TreeNode 2"
);
node2.Category =
"Prospects"
;
node2.Attributes.Add(
"ProspectID"
,
"456"
);
myTreeView.Nodes.Add(node2);
//Add the tree to the PanelItem - this could happen more than once for each PanelItem
myPanelItem.Controls.Add(myTreeView);
//Add the item to the PanelBar - this would occur for multiple items
RadPanelBar1.Items.Add(myPanelItem);
}
protected
void
XmlHttpPanel_ServiceRequest(
object
sender, RadXmlHttpPanelEventArgs e)
{
string
val = e.Value;
if
(val ==
"TreeNode 1"
)
{
RadXmlHttpPanel1.Controls.Add(LoadControl(
"Test1.ascx"
));
}
if
(val ==
"TreeNode 2"
)
RadXmlHttpPanel1.Controls.Add(LoadControl(
"Test2.ascx"
));
}
}
Any suggestions or thoughts are welcome.
Thanks in advance.