|
Rank: Member Groups: Member
Joined: 10/5/2008 Posts: 10
|
Hi i have a question, i added editor to a page, i need custom dropdown in toolbar, ok i did that by manually adding simple html control, <select></select>. In that controll i am populating some custom values, and on change event i add the selected value to the editor content, so my question is ias it possible to have asp.net dropdownlist control and databind it from server side? (i saw that it is possible to add that type of control, some lists like font and style are implemented in that way) but when i was trying to do that i wasn't able to databind that list from code behind.
Thanks for any help
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, It is possible to data binding the list from the server side. The key is that you need to get the listbox control first. It will be something like this:
Code: C#
DropDownList list = (DropDownList)
Editor1.FindControl("hc").FindControl("Your_List_Box_ID");
list.DataSource = your_data_source;
list.DataBind();
Hope this helps. Thanks
|
|
Rank: Member Groups: Member
Joined: 10/5/2008 Posts: 10
|
Tanks for code snippet, but doesn't work, i am getting null instead of dropdownlist control :)
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi,
Please create a full test page. Make sure the page runs (except for the null problem) independently. We will then take the page and correct the problem for you.
Thanks
|
|
Rank: Member Groups: Member
Joined: 10/5/2008 Posts: 10
|
here you are
Code: HTML/ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="EO.Web" Namespace="EO.Web" TagPrefix="eo" %>
<!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">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
<eo:Editor ID="txtContent" runat="server" Font-Bold="False" Font-Italic="False" Font-Overline="False"
Font-Strikeout="False" Font-Underline="False" FooterVisible="False" Height="297px"
HighlightColor="255, 255, 192" ToolBarSet="Custom" Width="700px" BorderStyle="Solid"
FontNames="Arial,Verdana" FontSizes="10,20,30" IndentWidth="5"
ToolBarSkin="Style1" BorderWidth="0px">
<FooterStyle CssText="background-color:#f8f8f8;border-bottom-color:black;border-bottom-style:solid;border-bottom-width:1px;border-left-color:black;border-left-style:solid;border-left-width:1px;border-right-color:black;border-right-style:solid;border-right-width:1px;padding-bottom:3px;padding-left:3px;padding-right:3px;padding-top:3px;" />
<BreadcrumbItemStyle CssText="border-right: darkgray 1px solid; padding-right: 3px; border-top: darkgray 1px solid; margin-top: 1px; padding-left: 3px; font-size: 12px; padding-bottom: 1px; border-left: darkgray 1px solid; padding-top: 1px; border-bottom: darkgray 1px solid; font-family: tahoma" />
<EmoticonStyle CssText="background-color:white;border-bottom-color:#c5d3ed;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#c5d3ed;border-left-style:solid;border-left-width:1px;border-right-color:#c5d3ed;border-right-style:solid;border-right-width:1px;border-top-color:#c5d3ed;border-top-style:solid;border-top-width:1px;padding-bottom:2px;padding-left:2px;padding-right:2px;padding-top:2px;" />
<BreadcrumbItemHoverStyle CssText="border-right: darkgray 1px solid; padding-right: 3px; border-top: darkgray 1px solid; margin-top: 1px; padding-left: 3px; font-size: 12px; padding-bottom: 1px; border-left: darkgray 1px solid; padding-top: 1px; border-bottom: darkgray 1px solid; font-family: tahoma; background-color:#e0e0e0;" />
<BreadcrumbItemSeparatorStyle CssText="width: 3px; height: 10px" />
<EmoticonDropDownStyle CssText="background-color:#f8f8f8;border-bottom-color:#d6d5d9;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#d6d5d9;border-left-style:solid;border-left-width:1px;border-right-color:#d6d5d9;border-right-style:solid;border-right-width:1px;border-top-color:#d6d5d9;border-top-style:solid;border-top-width:1px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;" />
<BreadcrumbLabelStyle CssText="padding-right: 6px; padding-left: 6px; font-size: 12px; padding-top: 1px; font-family: tahoma" />
<CustomHeaderTemplate>
<eo:ToolBar ID="ToolBar1" runat="server" SeparatorImage="00100304">
<Items>
<eo:ToolBarItem CommandName="Bold" ImageUrl="00101011" ToolTip="Bold">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="Italic" ImageUrl="00101012" ToolTip="Italic">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="Underline" ImageUrl="00101013" ToolTip="Underline">
</eo:ToolBarItem>
<eo:ToolBarItem Type="Separator">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="InsertOrEditImage" ImageUrl="00101033" ToolTip="Insert Image">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="InsertOrEditLink" ImageUrl="00101021" ToolTip="Insert Link">
</eo:ToolBarItem>
<eo:ToolBarItem Type="Separator">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="AlignLeft" ImageUrl="00101014" ToolTip="Align Left">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="AlignCenter" ImageUrl="00101015" ToolTip="Align Center">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="AlignRight" ImageUrl="00101016" ToolTip="Align Right">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="Fonts" ToolTip="Fonts" Type="Custom">
<CustomItem>
<div style="white-space: nowrap">
<asp:DropDownList
ID="FontDropDown" runat="server" Style="width: 115px">
<asp:ListItem>Arial</asp:ListItem>
<asp:ListItem>Courier New</asp:ListItem>
<asp:ListItem>Tahoma</asp:ListItem>
<asp:ListItem>Times New Roman</asp:ListItem>
<asp:ListItem>Verdana</asp:ListItem>
</asp:DropDownList>
</div>
</CustomItem>
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="FontSizs" ToolTip="FontSizes" Type="Custom">
<CustomItem>
<asp:DropDownList ID="FontSizeDropDown" runat="server" Style="width: 50px">
<asp:ListItem>8pt</asp:ListItem>
<asp:ListItem>10pt</asp:ListItem>
<asp:ListItem>12pt</asp:ListItem>
<asp:ListItem>14pt</asp:ListItem>
<asp:ListItem>16pt</asp:ListItem>
<asp:ListItem>20pt</asp:ListItem>
<asp:ListItem>32pt</asp:ListItem>
</asp:DropDownList>
</CustomItem>
</eo:ToolBarItem>
<eo:ToolBarItem Type="Separator">
</eo:ToolBarItem>
<eo:ToolBarItem ToolTip="Form variables" CommandName="FrmVariables" Type="Custom">
<CustomItem>
<select id="formVariables" style="width:120px" onchange="InsertFormVariable()">
</select>
</CustomItem>
</eo:ToolBarItem>
<eo:ToolBarItem ToolTip="Message variables" CommandName="MsgVariables" Type="Custom">
<CustomItem>
<asp:DropDownList ID="ddlMsgVariables" CssClass="DropDownlist" DataValueField="Id" DataTextField="DisplayName" runat="server">
<asp:ListItem>Arial</asp:ListItem>
<asp:ListItem>Courier New</asp:ListItem>
<asp:ListItem>Tahoma</asp:ListItem>
<asp:ListItem>Times New Roman</asp:ListItem>
<asp:ListItem>Verdana</asp:ListItem>
</asp:DropDownList>
<%--<select id="msgVariables" style="width:120px" onchange="InsertMsgVariable()">
</select>--%>
</CustomItem>
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="DesignMode" ImageUrl="00101051" ToolTip="Design Mode">
</eo:ToolBarItem>
<eo:ToolBarItem CommandName="HTMLMode" ImageUrl="00101052" ToolTip="HTML Mode">
</eo:ToolBarItem>
</Items>
<ItemTemplates>
<eo:ToolBarItem Type="Custom">
<NormalStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
<HoverStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
<DownStyle CssText="background-color:transparent;border-bottom-style:none;border-left-style:none;border-right-style:none;border-top-style:none;padding-bottom:1px;padding-left:2px;padding-right:2px;padding-top:2px;" />
</eo:ToolBarItem>
</ItemTemplates>
<NormalStyle CssText="padding-right: 4px; padding-left: 4px; padding-bottom: 3px; border-top-style: none; padding-top: 3px; border-right-style: none; border-left-style: none; border-bottom-style: none; cursor:hand; FONT-SIZE: 12px; FONT-FAMILY: Tahoma;" />
<HoverStyle CssText="border-right: #335ea8 1px solid; padding-right: 3px; border-top: #335ea8 1px solid; padding-left: 3px; padding-bottom: 2px; border-left: #335ea8 1px solid; padding-top: 2px; border-bottom: #335ea8 1px solid; background-color: #c2cfe5; cursor:hand; FONT-SIZE: 12px; FONT-FAMILY: Tahoma;" />
<DownStyle CssText="border-right: #335ea8 1px solid; padding-right: 2px; border-top: #335ea8 1px solid; padding-left: 4px; padding-bottom: 1px; border-left: #335ea8 1px solid; padding-top: 3px; border-bottom: #335ea8 1px solid; background-color: #99afd4; cursor:hand; FONT-SIZE: 12px; FONT-FAMILY: Tahoma;" />
</eo:ToolBar>
</CustomHeaderTemplate>
<BreadcrumbDropDownStyle CssText="border-top: gray 1px solid; border-right: gray 1px solid; padding-right: 2px; border-top: gray 1px; padding-left: 2px; padding-bottom: 2px; border-left: gray 1px solid; padding-top: 2px; border-bottom: gray 1px solid; background-color: #fafafa" />
<TabButtonStyles>
<NormalStyle CssText="font-family:Verdana;font-size:12px;padding-bottom:3px;padding-left:5px;padding-right:5px;padding-top:3px;" />
<HoverStyle CssText="background-color:#e0e0e0;border-bottom-color:#a7a6aa;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#a7a6aa;border-left-style:solid;border-left-width:1px;border-right-color:#a7a6aa;border-right-style:solid;border-right-width:1px;border-top-color:#a7a6aa;border-top-style:solid;border-top-width:1px;font-family:Verdana;font-size:12px;padding-bottom:2px;padding-left:4px;padding-right:4px;padding-top:2px;" />
<SelectedStyle CssText="border-bottom-color:#a7a6aa;border-bottom-style:solid;border-bottom-width:1px;border-left-color:#a7a6aa;border-left-style:solid;border-left-width:1px;border-right-color:#a7a6aa;border-right-style:solid;border-right-width:1px;border-top-color:#a7a6aa;border-top-style:solid;border-top-width:1px;font-family:Verdana;font-size:12px;padding-bottom:2px;padding-left:4px;padding-right:4px;padding-top:2px;" />
</TabButtonStyles>
<EditAreaStyle CssText="border-bottom-color:black;border-bottom-style:solid;border-bottom-width:1px;border-left-color:black;border-left-style:solid;border-left-width:1px;border-right-color:black;border-right-style:solid;border-right-width:1px;border-top-color:black;border-top-style:solid;border-top-width:1px;padding-bottom:0px;padding-left:0px;padding-right:0px;padding-top:0px;" />
</eo:Editor>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
and code behind
Code: C#
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
DropDownList list = (DropDownList)txtContent.FindControl("hc").FindControl("ddlMsgVariables");
list.Items.Clear();
}
}
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
Hi, Try the following code:
Code: C#
EO.Web.ToolBar tb = (EO.Web.ToolBar)txtContent.HeaderContainer.FindControl("ToolBar1");
EO.Web.ToolBarItem item = tb.FindItem("MsgVariables");
DropDownList list = (DropDownList)item.CustomItemInstance.FindControl("ddlMsgVariables");
list.Items.Clear();
This should work. Thanks!
|
|
Rank: Member Groups: Member
Joined: 10/5/2008 Posts: 10
|
Thanks a lot, this work :) a little workaround that also helped me http://aspadvice.com/blogs/name/archive/2008/03/31/Generic-Recursive-Find-Control-Extension.aspxnow i have to ways to get the ddl control :) Thanks one more time
|
|