Hello,
Thank you very much for your help, but I still have a problem.
The selected tree view node text/value is not displayed in the combobox (I'm trying to display as the combobox empty message and as a Label text)
Below is my code:
Default.aspx (This page is loading dynamiclly other user controls without problems):
<%@ Page Title="" Language="C#" MasterPageFile="~/Secure/MasterPages/DefaultMasterPage.master" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="GuidesNS.Secure_Mng_Guides_QA_Default" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
<style type="text/css">
.hide
{
visibility:hidden !important;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="MainPanel">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="MainPanel" LoadingPanelID="MainRadAjaxLoadingPanel" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel ID="MainRadAjaxLoadingPanel" Skin="Vista" runat="server">
</telerik:RadAjaxLoadingPanel>
<asp:Panel ID="MainPanel" Width="100%" BorderWidth="0" style="height:auto;" HorizontalAlign="Left" BorderColor="Black" runat="server">
<asp:Label ID="SelectedItemIDLabel" runat="server" Visible="false" Text=""></asp:Label>
<asp:Label ID="Label1" runat="server" Text=""></asp:Label>
<asp:Panel ID="OperationsPanel" runat="server" Width="100%" HorizontalAlign="Left">
<telerik:RadMenu ID="OperationsRadMenu" runat="server" Width="100%" OnItemClick="OperationsRadMenu_ItemClick">
<Items>
<telerik:RadMenuItem Text="Change Parent" Value="Folder" />
</Items>
</telerik:RadMenu>
<br /><br />
</asp:Panel>
<asp:Panel ID="MessagePanel" runat="server" Width="95%" style="margin-top:10px; margin-left:20px; margin-right:20px;" HorizontalAlign="Left">
<asp:Label ID="MessageLabel" runat="server" Font-Bold="true" ForeColor="Red" Font-Italic="true" Font-Size="14pt" Visible="false" Text=""></asp:Label>
</asp:Panel>
<asp:Panel ID="InernalPanel" runat="server" Width="95%" style="margin:10px;" HorizontalAlign="Left">
</asp:Panel>
</asp:Panel>
</asp:Content>
Default.aspx.cs:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using GuidesNS.CodeHelper;
namespace GuidesNS
{
public partial class Secure_Mng_Guides_QA_Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
Control control = null;
string ctrlname = Page.Request.Params.Get("__EVENTTARGET");
control = Page.FindControl(ctrlname);
if (control != null)
{
if (control.ID != "OperationsRadMenu" && OperationsRadMenu.SelectedItem != null)
{
PanelsMng.CleanPanelAndLoadUserControl(Page, InernalPanel, OperationsRadMenu.SelectedItem.Text.Replace(" ", "") + "UserControl.ascx");
}
}
else
{
if (OperationsRadMenu.SelectedItem != null)
{
PanelsMng.CleanPanelAndLoadUserControl(Page, InernalPanel, OperationsRadMenu.SelectedItem.Text.Replace(" ", "") + "UserControl.ascx");
}
}
}
}
protected void OperationsRadMenu_ItemClick(object sender, RadMenuEventArgs e)
{
string ssssssss = string.Empty;
//Hide the message
Guides.HideMessage(MessageLabel);
if (!e.Item.Text.Replace(" ", "").Equals(string.Empty))
{
PanelsMng.CleanPanelAndLoadUserControl(Page, InernalPanel, e.Item.Text.Replace(" ", "") + "UserControl.ascx");
}
}
}
}
ChangeParentUserControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="ChangeParentUserControl.ascx.cs" Inherits="GuidesNS.Secure_Mng_Guides_MultipleDocs_UserControls_DiffrentDocsPaths_ChangeParentUserControl" %>
<telerik:RadAjaxManagerProxy ID="radProxyOrganizationDropDown" runat="server">
<AjaxSettings>
<telerik:AjaxSetting AjaxControlID="rcbCompanyOrganization">
<UpdatedControls>
<telerik:AjaxUpdatedControl ControlID="rcbCompanyOrganization" />
</UpdatedControls>
</telerik:AjaxSetting>
</AjaxSettings>
</telerik:RadAjaxManagerProxy>
<telerik:RadScriptBlock ID="radScriptBlockOrganizationDropDown" runat="server">
<script type="text/javascript">
function nodeUserClicking_<%= ClientID %>(sender, args) {
var comboBox = $find("<%= rcbCompanyOrganization.ClientID %>");
comboBox.attachDropDown();
var node = args.get_node()
comboBox.set_text(node.get_text());
comboBox.trackChanges();
comboBox.get_items().getItem(0).set_value(node.get_text());
comboBox.commitChanges();
comboBox.hideDropDown();
}
function OnClientDropDownOpenedUserHandler_<%= ClientID %>(sender, eventArgs) {
var tree = sender.get_items().getItem(0).findControl("rtvCompanyUserOrganization");
var selectedNode = tree.get_selectedNode();
if (selectedNode) {
selectedNode.scrollIntoView();
}
}
function nodeUserClicked_<%= ClientID %>(sender, args)
{
args.get_domEvent().stopPropagation();
}
</script>
</telerik:RadScriptBlock>
<div style="float: left; width: 224px;">
<asp:SqlDataSource ID="GuidePowerShellSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:GeneralConnectionString %>"
SelectCommand="SELECT * FROM [guidesQA] where ([Type] Like '%Folder%') order by [Type],[Title] "></asp:SqlDataSource>
<telerik:RadComboBox ID="rcbCompanyOrganization"
Skin="Vista" runat="server" Height="140px" Width="215px"
EmptyMessage="Choose a user">
<Items>
<telerik:RadComboBoxItem runat="server"
meta:resourcekey="RadComboBoxItemResource1" />
</Items>
<ItemTemplate>
<telerik:RadTreeView ID="rtvCompanyUserOrganization" runat="server" DataValueField="SerID" OnNodeClick="NodeClick"
DataSourceID="GuidePowerShellSqlDataSource" DataFieldParentID="ParentID" DataFieldID="SerID" DataTextField="Title" >
<DataBindings>
<telerik:RadTreeNodeBinding Depth="0" Expanded="true" />
</DataBindings>
</telerik:RadTreeView>
</ItemTemplate>
</telerik:RadComboBox>
<br />
<asp:Label ID="ResultLabel" runat="server" Text=""></asp:Label>
<br /><br />
</div>
ChangeParentUserControl.ascx.cs:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using GuidesNS.CodeHelper;
namespace GuidesNS
{
public partial class Secure_Mng_Guides_MultipleDocs_UserControls_DiffrentDocsPaths_ChangeParentUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
rcbCompanyOrganization.OnClientDropDownOpened = "OnClientDropDownOpenedUserHandler_" + this.ClientID;
RadTreeView rtvCompanyOrganization = (RadTreeView)rcbCompanyOrganization.Items[0].FindControl("rtvCompanyUserOrganization");
rtvCompanyOrganization.OnClientNodeClicking = "nodeUserClicking_" + this.ClientID;
rtvCompanyOrganization.OnClientNodeClicked = "nodeUserClicked_" + this.ClientID;
rtvCompanyOrganization.Nodes.Clear();
rtvCompanyOrganization.DataSource = GetDataFromDB.GetDataTable("SELECT * FROM [guidesQA] where ([Type] Like '%Folder%') order by [Type],[Title]");
rtvCompanyOrganization.DataBind();
}
}
protected void NodeClick(object sender, RadTreeNodeEventArgs e)
{
RadTreeNode clickedNode = e.Node;
rcbCompanyOrganization.EmptyMessage = clickedNode.Text;
ResultLabel.Text = clickedNode.Text;
}
}
}
Note: the mehod "ChangePanelControlsVisibilty" removes all controls in a panel control.
Attached a screen-shot of this page.
Please, I need you help in order to solve this problem.
Regards,
Bader