<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server"> <script type="text/javascript"> //RadTreeNOde in Combobox function nodeClicking(sender, args) { var comboBox = $find("<%= DepartmentCombo.ClientID %>"); var node = args.get_node() comboBox.set_text(node.get_text()); comboBox.trackChanges(); comboBox.get_items().getItem(0).set_text(node.get_text()); comboBox.get_items().getItem(0).set_value(node.get_value()); comboBox.commitChanges(); comboBox.hideDropDown(); // Call comboBox.attachDropDown if: // 1) The RadComboBox is inside an AJAX panel. // 2) The RadTreeView has a server-side event handler for the NodeClick event, i.e. it initiates a postback when clicking on a Node. // Otherwise the AJAX postback becomes a normal postback regardless of the outer AJAX panel. //comboBox.attachDropDown(); } function StopPropagation(e) { if (!e) { e = window.event; } e.cancelBubble = true; } function OnClientDropDownOpenedHandler(sender, eventArgs) { var tree = sender.get_items().getItem(0).findControl("RadTreeView1"); var selectedNode = tree.get_selectedNode(); if (selectedNode) { selectedNode.scrollIntoView(); } } </script></telerik:RadCodeBlock> <telerik:RadComboBox runat="server" ID="DepartmentCombo" Width="100%" OnClientDropDownOpened="OnClientDropDownOpenedHandler" EmptyMessage="Хэлтэс албаны сонгоно уу" ExpandAnimation-Type="None" CollapseAnimation-Type="None" AutoPostBack="true" OnInit="DepComboBox_OnInit"> <Items> <telerik:RadComboBoxItem Value="0" Text="Хэлтэс албаа сонгоно уу" /> </Items> <ItemTemplate> <div id="div1"> <telerik:RadTreeView runat="server" ID="RadTreeView1" OnClientNodeClicking="nodeClicking" Width="100%" Height="240px"> </telerik:RadTreeView> </div> </ItemTemplate> </telerik:RadComboBox> <script type="text/javascript"> var divitem = document.getElementById("div1"); if (null != divitem) divitem.onclick = StopPropagation; </script>RadTreeView RadTree = (RadTreeView)DepartmentCombo.Items[0].FindControl("RadTreeView1"); Response.Write(RadTree.SelectedValue);PositionCombo i get msg "Input string was not in a correct format"<telerik:RadComboBox runat="server" ID="PositionCombo" Width="100%" EmptyMessage="Албан тушаалаа сонгоно уу" EnableLoadOnDemand="True" ShowMoreResultsBox="true" Height="150px" EnableVirtualScrolling="true" OnItemsRequested="PositionCombo_ItemsRequested" LoadingMessage="Ачааллаж байна..."> <HeaderTemplate> <table style="width: 100%" cellspacing="0" cellpadding="0"> <tr style="color: #417CAB; font-weight: bold;"> <td style="width: 100%;"> Нэр </td> </tr> </table> </HeaderTemplate> <ItemTemplate> <table style="width: 100%" cellspacing="0" cellpadding="0"> <tr> <td style="width: 100%;"> <%# DataBinder.Eval(Container, "Text")%> </td> </tr> </table> </ItemTemplate> </telerik:RadComboBox>protected void PositionCombo_ItemsRequested(object sender, RadComboBoxItemsRequestedEventArgs e) { RadTreeView RadTree = (RadTreeView)DepartmentCombo.Items[0].FindControl("RadTreeView1"); int ComboID = Convert.ToInt32(DepartmentCombo.SelectedValue); //0
int TReeID = Convert.ToInt32(RadTree.SelectedValue);//Input string was not in a correct format
DataTable data = _DepClass.GetPositionListForCbx(TReeID); int itemOffset = e.NumberOfItems; int endOffset = Math.Min(itemOffset + 500, data.Rows.Count); e.EndOfItems = endOffset == data.Rows.Count; for (int i = itemOffset; i < endOffset; i++) { RadComboBoxItem tempIT = new RadComboBoxItem(); tempIT.Value = data.Rows[i]["id"].ToString(); tempIT.Text = data.Rows[i]["title"].ToString(); PositionCombo.Items.Add(tempIT); tempIT.DataBind(); } e.Message = GetStatusMessage(endOffset, data.Rows.Count); }<paragraphs> <paragraph name="<H1 style='font-size: 14px; font-family: Arial; color:#808080'> Title </H2>" value="<h1 style='font-size: 14px; font-family:Arial; '> </h1>" /> <paragraph name="<H2 style='font-size: 12px; font-family: Arial; color:#808080'> Subhead </H2>" value="<h3 style='font-size: 12px; font-family:Arial; '> </h3>" /> <paragraph name="<H3 style='font-size: 10px; font-family: Arial; color:#808080'> Text </H3>" value="<h4 style='font-size: 10px; font-family:Arial; '> </h4>" /> </paragraphs>We have successfully used several Rad Controls in our preexisting AJAX enabled project, but are unable to get spell check working on the RadEditor.
When I click on the spell icon I get the following error:
Microsoft JScript runtime error: 'null' is null or not an object
The debugger shows the error as occurring in the following function:
// Name: HTMLEditor.EditPanel.debug.js // Assembly: AjaxControlToolkit // Version: 3.5.50508.0 // FileVersion: 3.5.50508 _invokingRequest: function(sender, args) { if (this._contentPrepared) { return; } var webRequest = args.get_webRequest(); var body = webRequest.get_body(); // change body here... var reg = new RegExp("([\\?&])(" + this.get_contentElement().name + "=)([^&$]*)([&$])", "g"); this._prepareContentForPostback(this.get_content()); >>> body = body.replace(reg, "$1$2" + escape(this.get_contentElement().value) + "$4"); <<<- body is null this._contentPrepared = true; webRequest.set_body(body); },I followed the directions for adding RadControls for ASP.NET AJAX to an existing application found here: http://www.telerik.com/help/aspnet-ajax/introduction-adding-radcontrols-prometheus-existing-application.html … and the recommendations for getting started with the editor here: http://www.telerik.com/help/aspnet-ajax/editor-getting-started.html
It should be noted the documentation specified configuration options in Step 9 which did not exist on the Smart Tag Menu (yes, we have the Telerik.Web.UI.dll in the project’s bin folder). Unable to add from the designer, I followed the directions found here: http://www.telerik.com/help/aspnet-ajax/editor-enable-spellcheck.html and manually added the spell check handler to my web.config, resulting in the editor displaying on the UI with a spell check icon on the toolbar.
I also tried substituting in a RadScriptManger in place of the ASP ScriptManger, but that only led to another problem:
Microsoft JScript runtime error: AjaxControlToolkit requires ASP.NET Ajax 4.0 scripts. Ensure the correct version of the scripts are referenced. If you are using an ASP.NET ScriptManager, switch to the AjaxScriptManager in System.Web.Ajax.dll, or use the ToolkitScriptManager in AjaxControlToolkit.dll.
We are developing in VS 2008. Any help is appreciated.
<telerik:RadWindow ID="GLLookupWindow" runat="server" Behaviors="Close" Width="900" Height="700" OnClientClose="UnhideIframe_OnClientClose"> <ContentTemplate> <asp:Button ID="hiddenButton" OnClientClick="return false;" runat="server" style="display:none" visible="false" /> <asp:Panel runat="server" ID="pnlGLLookup" Visible="true" TabIndex="-1"> <telerik:RadGrid AutoGenerateColumns="False" ID="GLLookup" OnItemCommand ="GLLookup_ItemCommand" AllowFilteringByColumn ="true" OnItemCreated="GLLookup_ItemCreated" EnableLinqExpressions="false" DataSourceID="SqlDataSourceGLLookupwindow" AllowSorting="true" runat="server" PagerStyle-AlwaysVisible="true" AllowPaging="true" PageSize ="20"> <GroupingSettings CaseSensitive="false" /> <MasterTableView DataKeyNames="GCMGRP,GCACCT,GCSACT,GCDEPT,GCDESC" AutoGenerateColumns="false" AllowFilteringByColumn="True" > <PagerStyle Mode="NumericPages" PageButtonCount="10" /> <Columns> <telerik:GridBoundColumn SortExpression="GCMGRP" HeaderText="Major" DataField="GCMGRP" UniqueName="GCMGRP" HeaderButtonType="TextButton" AllowFiltering="true" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="false" ShowFilterIcon="false" FilterDelay="4000" HeaderStyle-VerticalAlign="Bottom" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center"/> <telerik:GridBoundColumn HeaderText="Acct" DataField="GCACCT" UniqueName="GCACCT" AllowFiltering="true" SortExpression="GCACCT" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="false" ShowFilterIcon="false" FilterDelay="4000" /> <telerik:GridBoundColumn HeaderText="Sub" DataField="GCSACT" UniqueName="GCSACT" AllowFiltering="true" SortExpression="GCSACT" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="false" ShowFilterIcon="false" FilterDelay="4000" /> <telerik:GridBoundColumn HeaderText="Dept/Loc" DataField="GCDEPT" UniqueName="GCDEPT" AllowFiltering="true" SortExpression="GCDEPT" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" CurrentFilterFunction="EqualTo" AutoPostBackOnFilter="false" ShowFilterIcon="false" FilterDelay="4000" /> <telerik:GridBoundColumn HeaderText="Description" DataField="GCDESC" UniqueName="GCDESC" AllowFiltering="true" SortExpression="GCDESC" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-VerticalAlign="Bottom" CurrentFilterFunction="Contains" AutoPostBackOnFilter="false" ShowFilterIcon="false" FilterDelay="4000" /> </Columns> <ItemStyle Wrap="false" /> <PagerStyle Mode="NumericPages" AlwaysVisible="true"> </PagerStyle> </MasterTableView> <ClientSettings EnablePostBackOnRowClick="true" > </ClientSettings> </telerik:RadGrid> <asp:Button ID="clrFilters" runat="server" Text="Clear filters" OnClick="clrFilters_Click" /> </asp:Panel> </ContentTemplate> </telerik:RadWindow><script type="text/javascript"> //<!-- function onClientContextMenuShowing(sender, args) { var treeNode = args.get_node(); treeNode.set_selected(true); //enable/disable menu items setMenuItemsState(args.get_menu().get_items(), treeNode); } function onClientContextMenuItemClicking(sender, args) { var menuItem = args.get_menuItem(); var treeNode = args.get_node(); menuItem.get_menu().hide(); switch (menuItem.get_value()) { case "Rename": treeNode.startEdit(); break; case "addLocation": break; } } //this method disables the appropriate context menu items function setMenuItemsState(menuItems, treeNode) { for (var i = 0; i < menuItems.get_count(); i++) { var menuItem = menuItems.getItem(i); switch (menuItem.get_value()) { case "Rename": formatMenuItem(menuItem, treeNode, 'Rename "{0}"'); break; case "addLocation": if (treeNode.get_parent() == treeNode.get_treeView()) { menuItem.set_enabled(false); } else { menuItem.set_enabled(true); } break; } } //formats the Text of the menu item function formatMenuItem(menuItem, treeNode, formatString) { var nodeValue = treeNode.get_value(); if (nodeValue && nodeValue.indexOf("_Private_") == 0) { menuItem.set_enabled(false); } else { menuItem.set_enabled(true); } var newText = String.format(formatString, extractTitleWithoutMails(treeNode)); menuItem.set_text(newText); } //checks if the text contains (digit) function hasNodeMails(treeNode) { return treeNode.get_text().match(/\([\d]+\)/ig); } //removes the brackets with the numbers,e.g. Inbox (30) function extractTitleWithoutMails(treeNode) { return treeNode.get_text().replace(/\s*\([\d]+\)\s*/ig, ""); } } //--> </script><telerik:RadAjaxLoadingPanel ID="LocationsLoadingPanel" runat="server" Transparency="30" Skin="Vista"></telerik:RadAjaxLoadingPanel> <telerik:RadAjaxPanel ID="LocationsPanel" runat="server" LoadingPanelID="LocationsLoadingPanel"> <telerik:RadTreeView ID="LocationsTreeView" runat="server" EnableDragAndDrop="true" MultipleSelect="true" EnableDragAndDropBetweenNodes="true" AllowNodeEditing="true" OnContextMenuItemClick="LocationsTreeView_ContextMenuItemClick" OnClientContextMenuItemClicking="onClientContextMenuItemClicking" OnClientContextMenuShowing="onClientContextMenuShowing" OnNodeEdit="LocationsTreeView_NodeEdit"> <ContextMenus> <telerik:RadTreeViewContextMenu ID="MainContextMenu" runat="server"> <Items> <telerik:RadMenuItem Value="Rename" Text="Rename ..." Enabled="true" ImageUrl="images/icons/edit_48.png" PostBack="false"> </telerik:RadMenuItem> <telerik:RadMenuItem IsSeparator="true"> </telerik:RadMenuItem> <telerik:RadMenuItem Value="addLocation" Text="Add Location" ImageUrl="images/icons/add_16.png"> </telerik:RadMenuItem> </Items> <CollapseAnimation Type="none" /> </telerik:RadTreeViewContextMenu> </ContextMenus> </telerik:RadTreeView> </telerik:RadAjaxPanel>protected void LocationsTreeView_ContextMenuItemClick(object sender, RadTreeViewContextMenuEventArgs e){ RadTreeNode clickedNode = e.Node; switch (e.MenuItem.Value) { case "addLocation": RadTreeNode newLocation = new RadTreeNode(string.Format("Add Location")); newLocation.Selected = true; newLocation.ImageUrl = clickedNode.ImageUrl; clickedNode.Nodes.Add(newLocation); clickedNode.Expanded = true; //update the number in the brackets if (Regex.IsMatch(clickedNode.Text, unreadPattern)) clickedNode.Text = Regex.Replace(clickedNode.Text, unreadPattern, "(" + clickedNode.Nodes.Count.ToString() + ")"); clickedNode.Font.Bold = true; //set node's value so we can find it in startNodeInEditMode newLocation.Value = newLocation.GetFullPath("/"); startNodeInEditMode(newLocation.Value); // Add Location Record to Database string ParentID = clickedNode.Value; Guid ID = Guid.NewGuid(); string LocationID = ID.ToString(); string Name = newLocation.Text; LocationsTreeView_AddLocation(ParentID, LocationID, Name); break; case "Delete": clickedNode.Remove(); break; }}private void startNodeInEditMode(string nodeValue){ //find the node by its Value and edit it when page loads string js = "Sys.Application.add_load(editNode); function editNode(){ "; js += "var tree = $find(\"" + LocationsTreeView.ClientID + "\");"; js += "var node = tree.findNodeByValue('" + nodeValue + "');"; js += "if (node) node.startEdit();"; js += "Sys.Application.remove_load(editNode);};"; RadScriptManager.RegisterStartupScript(Page, Page.GetType(), "nodeEdit", js, true);}// Used when adding a Locationprotected void LocationsTreeView_AddLocation(string ParentID, string LocationID, string Name){ // Set parameters for insert locationDataSource.InsertParameters["LocationID"].DefaultValue = LocationID; locationDataSource.InsertParameters["ParentID"].DefaultValue = ParentID; locationDataSource.InsertParameters["Name"].DefaultValue = Name; // locationDataSource.Insert(); }// Used when renaming a Locationprotected void LocationsTreeView_NodeEdit(object sender, RadTreeNodeEditEventArgs e){ // Update Name on client side e.Node.Text = e.Text; // Update Name in database locationDataSource.UpdateParameters["Name"].DefaultValue = e.Text; locationDataSource.UpdateParameters["ID"].DefaultValue = e.Node.Value; locationDataSource.Update(); }