| ASPX PAGE | |
| ... | |
| <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %> | |
| ... | |
| <telerik:RadScriptManager ID="RadScriptManager1" runat="server" /> | |
| <telerik:RadComboBox ID="Categories" runat="server" | |
| OnClientSelectedIndexChanged="Categories_SelectedIndexChanged" | |
| OnItemsRequested="RadComboBox1_ItemsRequested" /> | |
| <telerik:RadComboBox ID="SubCategories" runat="server" | |
| OnItemsRequested="RadComboBox2_ItemsRequested" /> | |
| C# CODE-BEHIND | |
| using System; | |
| using System.Data; | |
| using System.Data.SqlClient; | |
| using System.Configuration; | |
| using System.Web; | |
| using System.Web.Security; | |
| using Telerik.Web.UI; | |
| public partial class tests_Default : System.Web.UI.Page | |
| { | |
| protected void Page_Load(object sender, EventArgs e) | |
| { | |
| // pre-populate Categories | |
| if (!Page.IsPostBack) | |
| { | |
| LoadCategories(); | |
| } | |
| } | |
| protected void LoadCategories() | |
| { | |
| SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); | |
| conn.Open(); | |
| SqlDataAdapter adapter = new SqlDataAdapter("SELECT id, category_name, sort_order FROM Categories", conn); | |
| DataTable dt = new DataTable(); | |
| adapter.Fill(dt); | |
| conn.Close(); | |
| Categories.DataTextField = "category_name"; | |
| Categories.DataValueField = "id"; | |
| Categories.DataSource = dt; | |
| // if datatable is null | |
| // do not bind dropdown | |
| if(dt.Rows.Count != 0) { | |
| Categories.DataBind(); | |
| } | |
| } | |
| protected void LoadSubCategories(string categoryID) | |
| { | |
| SqlConnection conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString); | |
| conn.Open(); | |
| SqlDataAdapter adapter = new SqlDataAdapter("SELECT id AS subcategoryID, subcategory_name FROM SubCategories WHERE category_id =" + categoryID, conn); | |
| DataTable dt = new DataTable(); | |
| adapter.Fill(dt); | |
| conn.Close(); | |
| SubCategories.DataTextField = "subcategory_name"; | |
| SubCategories.DataValueField = "subcategoryID"; | |
| SubCategories.DataSource = dt; | |
| SubCategories.DataBind(); | |
| } | |
| protected void Categories_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e) | |
| { | |
| //Response.Write("e.Text = " + e.Text + "<br>e.Value = " + e.Value); | |
| LoadSubCategories(e.Value.ToString()); | |
| } | |
| protected void RadComboBox1_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) | |
| { | |
| LoadCategories(); | |
| } | |
| protected void RadComboBox2_ItemsRequested(object o, RadComboBoxItemsRequestedEventArgs e) | |
| { | |
| Response.Write("e.Text = " + e.Text + "<br>e.Value = " + e.Value); | |
| LoadSubCategories(e.Value.ToString()); | |
| } | |
| } | |
<contextMenu forElement="IMG">
<tool name="SetImageProperties1" iconurl="~/RadControls/Editor/Skins/Default/Img/imageProperties.gif" />
</contextMenu>
and the following javascript beneath the RadEditor on the page:
RadEditorCommandList["SetImageProperties1"] =
function(commandName, editor, oTool)
{
editor.Fire('SetImageProperties', callBackFn);
function callBackFn(result)
{
if (result)
{
alert(result);
};
}
};
This is currently giving me a js error Object does not support this property or method. Also the icon URL is not displaying in the context menu even though it is valid and how would I put custom text in the context menu text? I was trying to use this approach which is similar to the following thread: http://www.telerik.com/community/forums/thread/b311D-taged.aspx
Thank you for your help.
