Custom Button for linking to internal pages

Last post 01-18-2006, 9:07 PM by saurabh. 12 replies.
Sort Posts: Previous Next
  •  03-28-2005, 10:03 PM 5046

    Custom Button for linking to internal pages

    I have crreated and added a custom button.
     
    The popup has a dropdown listbox that is populated and databound to the database. I retrieve the pageid and Page name.
     
    When a User selects an item in the drop down and clicks the insert button I want to insert a link like PageDisplay.aspx?pageid=8  where 8 is the page number.
     
    How do I return the value to the editor?
     
    Thanks
     
    Andy
  •  03-30-2005, 4:39 PM 5135 in reply to 5046

    Re: Custom Button for linking to internal pages

    Andy I'd be very interested in this also, we'd like our users to be able to select an existing page from our site (using DotNetNuke) and insert it into a link.

    Would be happy to work with you on the code -> might be able to help you with your problem..

    Cheers,
    Andrew

  •  03-30-2005, 4:47 PM 5136 in reply to 5135

    Re: Custom Button for linking to internal pages

  •  03-30-2005, 4:57 PM 5138 in reply to 5135

    Re: Custom Button for linking to internal pages

    I got it to work. Here is the code so far:
     
    Dim EditorDL As CuteEditor.RichDropDownList
     

    EditorDL =

    New CuteEditor.RichDropDownList(Editor1)
    EditorDL = Editor1.ToolControls("Links").Control
     
     

    EditorDL.Items.Clear()

    EditorDL.Items.Add("Internal Links")

    EditorDL.Items.Add("home page", "Default.aspx?pageId=8")
     
    I still need to get the page info from the DB but that should be easy
     
    Andy
  •  03-30-2005, 5:01 PM 5139 in reply to 5138

    Re: Custom Button for linking to internal pages

  •  03-30-2005, 11:05 PM 5146 in reply to 5139

    Re: Custom Button for linking to internal pages

    Hey Adam,

    For DotNetNuke, I assume I would need to perform this in the provider file, however what event would I need to place it in?

    Would I need to over-ride OnLoad?  And if so, how would I get a reference to the Editor?

    Cheers,
    Andrew

  •  03-30-2005, 11:11 PM 5148 in reply to 5146

    Re: Custom Button for linking to internal pages

    Andrew,
     
    First please download the version 4.0.0.6 from:
     
     
    This is an official version.

    >> For DotNetNuke,
     
    Please wait a sec. I will write some code showing you how to do that.
     
     

    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

  •  03-30-2005, 11:21 PM 5149 in reply to 5148

    Re: Custom Button for linking to internal pages

    Andrew,


    Step 1.    Locate and open CEHtmlEditorProvider.vb, Find Public Sub New() 

    Step 2.   
          .......

          cntlCE.DisableItemList = "Save".
        
         If Not cntlCE.ToolControls("insertcustombutonhere") Is Nothing Then

                    Dim container As System.Web.UI.Control
                    container = Editor2.ToolControls("insertcustombutonhere").Control
                    Dim dropdown As CuteEditor.RichDropDownList
                    dropdown = New CuteEditor.RichDropDownList(Editor2)
                    dropdown.Attributes("onchange") = "CuteEditor_DropDownCommand(this,'InsertLink')"
                    'must set this css name
                    dropdown.CssClass = "CuteEditorDropDown"
                    'add the first item (caption)
                    'the culture-text would be auto replaced..
                    dropdown.Items.Add("[[Links]]", "")
                    'hide the first item (caption) in the float-panel
                    dropdown.RichHideFirstItem = True
                    'add the items here every times
                    dropdown.Items.Add("http://www.asp.net/")
                    '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
                    'or add items here if(!IsPostBack)
                    If Not Page.IsPostBack Then
                        dropdown.Items.Add("Microsoft", "http://www.microsoft.com/")
                        dropdown.Items.Add("<font color=red>CuteSoft</font>", "*CuteSoft*", "http://www.cutesoft.net/")
                    End If
        End If

    Step 3.  Recompile the project.



    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

  •  03-30-2005, 11:21 PM 5150 in reply to 5148

    Re: Custom Button for linking to internal pages

    Awesome thanks Adam.

    I'm half way there, as I can use the DotNetNuke.Common.Globals.GetPortalTabs method to get a nicely formatted list of pages.

    Just need to iterate through them and add the link value to each when adding it to the dropdownlist.

    I created a 'holder' in the config file but it doesn't seem to recognise it in the code. Will be keen to see your code.

    Cheers,
    A
  •  03-30-2005, 11:35 PM 5152 in reply to 5150

    Re: Custom Button for linking to internal pages

    ahh OK, i'll try it in New().

    So how do I get a reference to an instance of the editor class... 'editor2' won't exist as its not declared as a control on the aspx file (since there isn't one).

    PS - This is DNN 3.0.12. The provider in DNN3.x is different and all other properties (such as cntlCE.DisableItemList = "Save") are set in the Initialize() event, not new().
  •  03-31-2005, 12:28 AM 5164 in reply to 5152

    Re: Custom Button for linking to internal pages

    OK, worked when I kept it in the Initialize() event, and changed the reference to the existing cntlCE reference.

    Cheers,
    Andrew

  •  03-31-2005, 2:35 AM 5165 in reply to 5164

    Re: Custom Button for linking to internal pages

    Hi Adam, I've got that all working fine, and will post the code after cleaning it up a bit, incase anyone asks a similar question for DNN.

    Anyway, wondering if you could clear something up for me:

    One of the overloads for the Items.Add method of the CuteEditor.RichListItemCollection is:
    Public Sub Add(ByVal html As String, ByVal text As String, ByVal value As String)

    Using the example you have provided in the code snippets:
    dropdown.Items.Add("<font color=red>CuteSoft</font>", "*CuteSoft*", "http://www.cutesoft.net/")

    I would expect:
    1) "Cutesoft" appears in RED in the dropdown box
    2) The anchor link points to "http://www.cutesoft.net/"
    3) The TEXT displayed for the link would be "*Cutesoft*", if a user hadn't preselected any text before making the selection.

    I've not managed to get the *Cutesoft* part to display.. It just defaults to the URL link instead..

    Is this the expected behaviour?

    Cheers,
    Andrew



  •  01-18-2006, 9:07 PM 14852 in reply to 5046

    Re: Custom Button for linking to internal pages

     andytauber wrote:
    I have crreated and added a custom button.
     
    The popup has a dropdown listbox that is populated and databound to the database. I retrieve the pageid and Page name.
     
    When a User selects an item in the drop down and clicks the insert button I want to insert a link like PageDisplay.aspx?pageid=8  where 8 is the page number.
     
    How do I return the value to the editor?
     
    Thanks
     
    Andy
     
    Hi,
     
    I am trying to do something very similar with our CMS. I would like to replace the hyperlink icon in the editor with a custom hyperlink item. I do not want to use the drop down list at all. Also, I will need to allow the users to be able to edit the following attributes for the link:
     
    1. Title
    2. Target
    3. Name
     
    I have looked through the forums and the documentation but can't find details for the JavaScript API. The following URL
    http://www.cutesoft.net/asp/JavaScript-API.asp does not help at all as it is a very simplified example of how to use the API. Is there a detailed documentation for the functions such as InsertLink?
     
    Thanks.
View as RSS news feed in XML