dropdownlist in toolbar populated from a database

Last post 09-18-2006, 4:30 AM by the4bs. 6 replies.
Sort Posts: Previous Next
  •  06-26-2006, 8:06 AM 20469

    dropdownlist in toolbar populated from a database

    Hi,

    I would like to add a normal dropdownlist to the Cute Editor toolbar.
     
    The dropdownlist needs to be populated from a database.
     
    On saving the contents of the editor, the selected value of the dropdownlist also needs to be saved to a database.
     
    Do you have an example of this along with example code please?
     
    I have looked at the code for adding a custom button. This did not help me.
     
    I am using  asp.net 2.0 with VB.
     
     
    Below is the code I am currently using in code behind:
     
     
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

     
    PopulateTemplateDropDown()
     
    End Sub
     

    Protected Sub PopulateTemplateDropDown()

    Dim PageID, NewPage As Integer

    PageID = Session(SessTypes.TreeViewID)

    If (Request.QueryString("Edit")) = Nothing Then

    NewPage = 1

    Else

    NewPage = 0

    End If

    Dim objRdr As SqlClient.SqlDataReader = Nothing

    objRdr = SiteDB.SiteGetTemplatesByPage(PageID, NewPage)

    Dim ddlTemplates

    ddlTemplates = Editor1.FindControl("ddlTemplates")

    Try

    If Not ddlTemplates Is Nothing Then

    ddlTemplates.DataTextField = "Name"

    ddlTemplates.DataValueField = "TemplateID"

    ddlTemplates.DataSource = objRdr

    ddlTemplates.DataBind()

    ddlTemplates.Items.Insert(0, New ListItem("Select", ""))

    End If

    Finally

    objRdr.Close()

    End Try

    End Sub
     
     
     
     
    In config file:

    <item type="dropdown" id="ddlTemplates" name="ddlTemplates" text="[[Template]]" postback="True" RenderItemBorder="true" commandname="SaveTemplate" commandargument="SaveTemplate" />

     
    The above does not generate an error, but does not populate the dropdownlist with values from the database.
     
    Thank you in advance.
  •  06-26-2006, 11:37 AM 20481 in reply to 20469

    Re: dropdownlist in Cute Editor toolbar populated from a database *Very Urgent*

  •  06-26-2006, 11:48 AM 20483 in reply to 20481

    Re: dropdownlist in Cute Editor toolbar populated from a database *Very Urgent*

    For the server side controls, please check the following article:
     
    How to create a custom button (Server Control) and register it with the editor toolbar template?
     
     
    Example code:
     
            Dim hello As New System.Web.UI.WebControls.Button
            hello.Text = "Hello"
            hello.Style("vertical-align") = "middle"
            hello.CommandName = "Hello"
            AddHandler hello.Click, AddressOf hello_Click
            Dim world As New System.Web.UI.WebControls.Button
            world.Text = "Hello"
            world.Style("vertical-align") = "middle"
            world.CommandName = "world"
            AddHandler hello.Click, AddressOf world_Click

            Editor1.RegisterCustomButton("hello", hello)
            Editor1.RegisterCustomButton("world", world)
     
     

    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

  •  06-27-2006, 4:38 AM 20502 in reply to 20483

    Re: dropdownlist in Cute Editor toolbar populated from a database *Very Urgent*

    Thank you for your suggestions.
    Unfortunately, they don't seem to answer my question.
     
    I have a dropdown in the toolbar that needs to be populated by the database.
    On submitting the contents of the editor to the database, I also need to submit the selected value of the dropdown to the database.
    The dropdown does not enter anything into the editor textarea.
     
    Rather than giving the button example so that we can try to work out how to adapt it to what we want, could I ask/suggest that your company make a simple dropdown example. There seems to be the demand for it on this forum. There are a lot of questions about dropdowns and it does not seem to be possible to get this information from the documentation.
     
    Thank you.
  •  06-27-2006, 8:57 AM 20507 in reply to 20469

    Re: *Very Urgent* dropdownlist in Cute Editor toolbar populated from a database

    So I got  a dropdowlist populated using a database:
     
     

    Dim container As System.Web.UI.Control

    container = Editor1.ToolControls("custom").Control

    Dim dropdown As CuteEditor.RichDropDownList

    dropdown = New CuteEditor.RichDropDownList(Editor1)

    'set the onchange statement

    'use the CuteEditor_DropDownCommand => editor.ExecCommand('InsertLink',false,ddl.value)

    ' dropdown.Attributes("onchange") = "CuteEditor_DropDownCommand(this,'InsertLink')"

    'must set this css name

    dropdown.CssClass = "~/styles/screen.css"

    'add the first item (caption)

    'the culture-text would be auto replaced..

    dropdown.Items.Add("[[Template]]", "")

    'hide the first item (caption) in the float-panel

    dropdown.RichHideFirstItem = True

    'add the items here every times

    'add - !!!

    'if the statements put before Controls.Add , the statements must be executed every time

    container.Controls.Add(dropdown)

    'if the statements put after Controls.Add the statements could be executed only the first time

    Dim objRdr As SqlClient.SqlDataReader = Nothing

    objRdr = SiteDB.SiteGetTemplatesByPage(PageID, NewPage)

    If Not Page.IsPostBack Then

    Try

    While objRdr.Read

    dropdown.Items.Add(objRdr("Name"), objRdr("TemplateID"))

    End While

    Finally

    objRdr.Close()

    End Try

    End If

  •  06-27-2006, 11:15 AM 20526 in reply to 20507

    Re: *Very Urgent* dropdownlist in Cute Editor toolbar populated from a database

  •  09-18-2006, 4:30 AM 22790 in reply to 20481

    Re: dropdownlist in Cute Editor toolbar populated from a database *Very Urgent*

    Empty
View as RSS news feed in XML