I'm using Telerik Controls version 2008.1.619.35. I have a master page containing a splitter with two panes: the left pane has a panelbar navigation, the right pane is for the main content.
Now I’d like to apply different CSS classes to the right splitter pane, to achieve different color schemes, depending on the selected panelbar item.
I tried to do this in the Page_Load of the master page. Here the simplified code:
RightSplitterPane.CssClass = NavigationPanelBar.SelectedItem.Text; |
But when I call the page, I get the exception “Object reference not set to an instance of an object.” for that line. Obviously I’m missing something, but what? Any ideas?
5 Answers, 1 is accepted
0

xws-mika
Top achievements
Rank 1
answered on 23 Jul 2008, 08:30 AM
OK, here's a simplified example for my problem (I called the file "PanelBar_SelectedItemDemo.aspx"):
And file "Navigation.xml" contains this:
Expected behaviour:
Label "Output" should show the currently selected panelbar item. If no item is selected, output should be "NO SELECTED ITEM!".
Result:
Output is always "NO SELECTED ITEM!", even if an item is selected!
Question:
What am I doing wrong??
<%@ Page Language="C#" AutoEventWireup="true" Theme="" %> | |
<%@ Register TagPrefix="radp" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> | |
<script runat="server"> | |
protected void Page_Load(object sender, EventArgs e) | |
{ | |
NavigationPanel.LoadContentFile("Navigation.xml"); | |
try | |
{ | |
Output.Text = NavigationPanel.SelectedItem.ToString(); | |
} | |
catch | |
{ | |
Output.Text = "NO SELECTED ITEM!"; | |
} | |
} | |
</script> | |
<!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>Untitled Page</title> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<asp:ScriptManager ID="ScriptManager1" runat="server" /> | |
<radctrl:RadPanelbar ID="NavigationPanel" runat="server" PersistStateInCookie="True" Skin="Outlook"></radctrl:RadPanelbar> | |
Output: <asp:Label ID="Output" runat="server"></asp:Label> | |
</form> | |
</body> | |
</html> | |
And file "Navigation.xml" contains this:
<?xml version="1.0" encoding= "utf-8" ?> |
<PanelBar> |
<Item Text="RadEditor" Postback="true" NavigateUrl="PanelBar_SelectedItemDemo.aspx" /> |
<Item Text="RadPanelBar" Postback="true" NavigateUrl="PanelBar_SelectedItemDemo.aspx" /> |
<Item Text="RadMenu" Postback="true" NavigateUrl="PanelBar_SelectedItemDemo.aspx" /> |
<Item Text="RadTabStrip" Postback="true" NavigateUrl="PanelBar_SelectedItemDemo.aspx" /> |
</PanelBar> |
Expected behaviour:
Label "Output" should show the currently selected panelbar item. If no item is selected, output should be "NO SELECTED ITEM!".
Result:
Output is always "NO SELECTED ITEM!", even if an item is selected!
Question:
What am I doing wrong??
0
Hi ,
I suspect that the reason for the problem is that you did not mark anyone of the items of the xml file with Selected=True property.
Please see the attached projet which works as expected. If this does not help you, could you please modify it so the problem to appear and send us back to us to test it locally?
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I suspect that the reason for the problem is that you did not mark anyone of the items of the xml file with Selected=True property.
Please see the attached projet which works as expected. If this does not help you, could you please modify it so the problem to appear and send us back to us to test it locally?
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

xws-mika
Top achievements
Rank 1
answered on 23 Jul 2008, 09:53 AM
Hi Rosi,
thank you for the quick response! I see what you mean, and it works in my example if I preselect an item in the XML file, but then the output is always this preselected item, even if I click on another item. What I'm looking for is the possibility to get the currently (!) selected item.
Background of my problem (see also my first post): I have the panelbar on a master page, and I'd like to track the changes of the panelbar selection in all pages that use this master. I know how to do this with client-side JavaScript, but I'd prefer to do it on the server side. Is this possible?
thank you for the quick response! I see what you mean, and it works in my example if I preselect an item in the XML file, but then the output is always this preselected item, even if I click on another item. What I'm looking for is the possibility to get the currently (!) selected item.
Background of my problem (see also my first post): I have the panelbar on a master page, and I'd like to track the changes of the panelbar selection in all pages that use this master. I know how to do this with client-side JavaScript, but I'd prefer to do it on the server side. Is this possible?
0
Accepted
Hello ,
In this case setting the PersistStateInCookie property to true should be enough. Also I suggest you use the SelectedItem in the PreRender event of RadPanelBar instead of the Page_Load event handler.
See our online example for more details.
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
In this case setting the PersistStateInCookie property to true should be enough. Also I suggest you use the SelectedItem in the PreRender event of RadPanelBar instead of the Page_Load event handler.
See our online example for more details.
Regards,
Rosi
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
0

xws-mika
Top achievements
Rank 1
answered on 23 Jul 2008, 01:03 PM
The online example contained exactly what I was looking for. thanks!!