Re: Get values from dropdown in toolbar - to insert into database

  •  06-27-2006, 11:54 AM

    Re: Get values from dropdown in toolbar - to insert into database

    No, I'm afraid that didn't help. I cannot see how the code refers to a dropdown in the toolbar or how it gets the value of the selected item of the dropdown in the toolbar. The example you show gets the information from the Editor textarea. I can do that, but I cannot get the value from the dropdown in the toolbar.
     
    This is the code of the page I am writing:
     
    Imports Globals
    Imports System.Data
    Partial Class CCuteEditor
    Inherits System.Web.UI.Page
     
     
      Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If (Request.QueryString("Edit")) <> Nothing Then

          btnToEditForm.Visible = True
        Else
          btnToEditForm.Visible = False
        End If
        If Not Page.IsPostBack Then
          GetHTML()
          'Cute Editor Settings
          Editor1.EditorWysiwygModeCss = "~/styles/AcmsMain.css,~/styles/screen.css"
          Editor1.EditorBodyStyle = "~/styles/screen.css"
          Editor1.RenderRichDropDown = "False"
          Editor1.ThemeType = CuteEditor.ThemeType.Office2003
          Editor1.ShowPreviewMode = False
          Editor1.EnableStripScriptTags = False
        End If
        'Adding custom buttons
        Dim tc As CuteEditor.ToolControl
        tc = Editor1.ToolControls("insertcustombutonhere")
        If Not tc Is Nothing Then
          Dim AddImage As New System.Web.UI.WebControls.Image()
          AddImage.ToolTip = "Insert Image"
          AddImage.ImageUrl = "~/CuteSoft_Client/CuteEditor/Images/eximage.gif"
          AddImage.CssClass = "CuteEditorButton"
          AddImage.Attributes("onclick") = "BLOCKED SCRIPTpopUp('AddImage.aspx')"
          tc.Control.Controls.Add(AddImage)
          Dim AddFile As New System.Web.UI.WebControls.Image()
          AddFile.ToolTip = "Insert File"
          AddFile.ImageUrl = "~/CuteSoft_Client/CuteEditor/Images/AddFile.gif"
          AddFile.CssClass = "CuteEditorButton"
          AddFile.Attributes("onclick") = "BLOCKED SCRIPTpopUp('AddFile.aspx')"
          tc.Control.Controls.Add(AddFile)

          Dim AddMedia As New System.Web.UI.WebControls.Image()
          AddMedia.ToolTip = "Insert Media"
          AddMedia.ImageUrl = "~/CuteSoft_Client/CuteEditor/Images/media.gif"
          AddMedia.CssClass = "CuteEditorButton"
          AddMedia.Attributes("onclick") = "BLOCKED SCRIPTpopUp('AddMedia.aspx')"
          tc.Control.Controls.Add(AddMedia)
          Dim AddLink As New System.Web.UI.WebControls.Image()
          AddLink.ToolTip = "Insert link"
          AddLink.ImageUrl = "~/CuteSoft_Client/CuteEditor/Images/link.gif"
          AddLink.CssClass = "CuteEditorButton"
          AddLink.Attributes("onclick") = "BLOCKED SCRIPTpopUp('AddLink.aspx')"
          tc.Control.Controls.Add(AddLink)
        End If
        PopulateTemplateDropDown()
       
      End Sub
     
     
      Protected Sub Editor1_Initializing(ByVal sender As Object, ByVal e As System.EventArgs) Handles Editor1.Initializing
        Dim ddlTemplates As New System.Web.UI.WebControls.DropDownList '?
        Editor1.RegisterCustomButton("ddlTemplates.SelectedItem.Value", ddlTemplates) '?
      End Sub
     
     
      Protected Sub Editor1_PostBackCommand(ByVal Sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs) Handles Editor1.PostBackCommand
        Try
          If String.Compare(e.CommandName, "Save", True) = 0 Then
            Submit()
          End If
        Catch ex As Exception
          LogError(ex)
          lblError.Text = "There was an error proccessing your request. Please try again."
        End Try
      End Sub
     
     
      Protected Sub Submit()
        Dim UserID As Integer = Session(SessTypes.UserID)
        Dim PageID, TemplateID As Integer
        Dim HTML As String
        If (Request.QueryString("Edit")) = Nothing Then
          PageID = Session(SessTypes.NewPageID)
        Else
          PageID = Integer.Parse(Request.QueryString("ID"))
        End If
        HTML = Editor1.Text

        TemplateID = 1 ' **** FROR TESTING ONLY ****
     
        Dim ddlTemplates As CuteEditor.RichDropDownList
        ddlTemplates = Editor1.FindControl("ddlTemplates")
        If Not ddlTemplates Is Nothing Then
          Response.Write("Template " & ddlTemplates.SelectedItem.Value)
        End If
     
        Try
          SiteDB.SiteInsertPageHTML(UserID, PageID, HTML, TemplateID)
       
          lblMessage.Text = "<br/>Your page has been saved to the database. Please wait a moment while it reloads in the editor.<br/>"
        Catch ex As Exception
          LogError(ex)
          lblError.Text = "There was an error with adding your page."
        End Try
      End Sub
     
     
      Protected Sub GetHTML()
        Dim PageID As Integer
        If (Request.QueryString("Edit")) = Nothing Then
          PageID = Session(SessTypes.NewPageID)
        Else
          PageID = Integer.Parse(Request.QueryString("ID"))
        End If
        Dim objRdr As SqlClient.SqlDataReader
        objRdr = SiteDB.SiteSelectPageHTML(PageID)
        Try
          While objRdr.Read()
            Editor1.Text = objRdr("HTML")
          End While
        Finally
          objRdr.Close()
        End Try
      End Sub
     
     
      Protected Sub btnBackToTreeView_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBackToTreeView.Click

     
        Response.Redirect("~/home.aspx?ZoomID=-1", True) '

      End Sub
     
     
      Protected Sub btnToEditForm_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnToEditForm.Click
        Dim PageID As Integer
        PageID = Integer.Parse(Request.QueryString("ID"))
        Response.Redirect("AddEditPage.aspx?Edit=1&ID=" & PageID, True)
      End Sub
      Protected Sub Preview(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPreview.Click
      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 container As System.Web.UI.Control
        container = Editor1.ToolControls("custom").Control
        Dim ddlTemplates As CuteEditor.RichDropDownList
        ddlTemplates = 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
        ddlTemplates.CssClass = "~/styles/AcmsMain.css"
        'add the first item (caption)
        'the culture-text would be auto replaced..
        ddlTemplates.Items.Add("[[Template]]", "")
        'hide the first item (caption) in the float-panel
        ddlTemplates.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(ddlTemplates)
        '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
              ddlTemplates.Items.Add(objRdr("Name"), objRdr("TemplateID"))
            End While
          Finally
            objRdr.Close()
          End Try
        End If
      End Sub
     
    End Class
View Complete Thread