RichDropDownList server side onChange event

Last post 08-05-2008, 6:18 PM by jscadden. 4 replies.
Sort Posts: Previous Next
  •  08-04-2008, 11:21 PM 42729

    RichDropDownList server side onChange event

    How do I hook up a server side onChange/selectedIndexChanged event for my custom RichDropDownList?  I have read the example "customize_dropdown.aspx".  That example shows connecting to an existing command "InsertLink".  I need to connect to method within my codebehind class.
     
    I want to be able to select an item from my dropdown list and based on the item selected I will retrieve information from the database and manipulate the Editor.text.
     
    Thank you for you help.
  •  08-05-2008, 10:35 AM 42740 in reply to 42729

    Re: RichDropDownList server side onChange event

    jscadden,
     
    To add a server control, please use the following example. RichDropDownList doesn't support server side event. You need to use the regular ASP.NET DropDownList:
     
    <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>

    create/register a custom button (Server Control) to Cute Editor

    How to create/register a custom button (Server Control) so that it can be used in the template?( C# | VB )

    This example demonstrates how easy it can be to add Server Controls to the CuteEditor and register it into Cute Editor toolbar.


    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-05-2008, 11:40 AM 42746 in reply to 42740

    Re: RichDropDownList server side onChange event

    Thank you for your reply.  I have been able to get my dropdown to show up on the toolbar using the above example.  It won't work until you specity the dropdown in the following call.
     
    TemplateItemList="[Bold,Italic]/[World,clients]"
     
    My problem now is that I am not able to get it to fire the SelectedItemChanged event.  I am able to get a button's "click" event to work, but not a dropdown's SelectedItemChanged event.  When I select an item in the dropdown it doesn't change to the selected item.  Can you provide an example of adding a custom serverside dropdown control that responds to an event when selecting an item?
     
    What am I missing?
  •  08-05-2008, 3:29 PM 42760 in reply to 42746

    Re: RichDropDownList server side onChange event

    Please try the following code:
     
    <script  runat="server">
    Sub submit(sender As Object, e As EventArgs)
       mess.Text="You selected " & drop1.SelectedItem.Text
    End Sub
    </script>

    <html>
    <body>

    <form runat="server">
    <asp:DropDownList id="drop1" runat="server">
    <asp:ListItem>Item 1</asp:ListItem>
    <asp:ListItem>Item 2</asp:ListItem>
    <asp:ListItem>Item 3</asp:ListItem>
    <asp:ListItem>Item 4</asp:ListItem>
    <asp:ListItem>Item 5</asp:ListItem>
    <asp:ListItem>Item 6</asp:ListItem>
    </asp:DropDownList>
    <asp:Button Text="Submit" OnClick="submit" runat="server"/>
    <p><asp:label id="mess" runat="server"/></p>
    </form>

    </body>
    </html>

    asp.net Chat http://cutesoft.net/ASP.NET+Chat/default.aspx
    Web Messenger: http://cutesoft.net/Web-Messenger/default.aspx
    asp.net wysiwyg editor: http://cutesoft.net/ASP.NET+WYSIWYG+Editor/default.aspx
    asp wysiwyg html editor: http://cutesoft.net/ASP
    asp.net Image Gallery: http://cutesoft.net/ASP.NET+Image+Gallery/default.aspx
    Live Support: http://cutesoft.net/live-support/default.aspx

  •  08-05-2008, 6:18 PM 42763 in reply to 42760

    Re: RichDropDownList server side onChange event

    Ok.. Firefox was hanging me up.  I am able to get the SelectedIndexChanged event to fire using the arrow keys and enter key on the keyboard.  The DropDownList doesn't respond to mouse clicks when running under FireFox.  Everything seems to function properly under IE 7.  Any suggestions or fixes for FireFox?
     
    Here is a code sample:
    <%@ Page Language="C#" AutoEventWireup="true" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <script runat="server" >
        protected override void OnInit(EventArgs args)
        {
            editor.Initializing += new EventHandler(editor_Initializing);
            base.OnInit(args);
        }

        protected void editor_Initializing(object sender, EventArgs e)
        {
            AddClientDropDownList();
        }

        private void AddClientDropDownList()
        {
            DropDownList list = new DropDownList();
            list.AutoPostBack = true;
            list.Items.Add(new ListItem("Clients", "0"));
            list.Items.Add(new ListItem("Microsoft", "1"));
            list.Items.Add(new ListItem("CuteSoft", "2"));
            list.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);
            list.CssClass = "CuteEditorDropDown";
            editor.RegisterCustomButton("clients", list);
        }

        void list_SelectedIndexChanged(object sender, EventArgs e)
        {
            editor.Text = "list selected";
        }
    </script>
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
       
        <div>
            <CE:Editor id="editor"  Width="100%" Height="600" TemplateItemList="[clients]" runat="server" ></CE:Editor>
        </div>
        </form>
    </body>
    </html>

     
View as RSS news feed in XML