Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 01, 2010 @ 16:50
    Jeroen Breuer
    0

    Datatype on normal page or UserControl

    Hello,

    I'm creating a custom section in which I display some normal pages and usercontrols. The problem is that on these normal pages I'd like to show some datatypes? So far every time I needed to do this I took the existing datatype from the Umbraco source code and modified it so it works as a normal control. Some controls already work out of the box like the media picker for example:

    <%@ Register TagPrefix="UmbracoControls" Namespace="umbraco.controls" Assembly="umbraco" %>
    <UmbracoControls:ContentPicker ID="MediaPickerUpload" runat="server" AppAlias="media" TreeAlias="media" ModalHeight="250" ShowDelete="false"/>
    

    Is there some default way I can use all existing datatypes on a normal page or UserControl?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 02, 2010 @ 08:50
    Jeroen Breuer
    0

    Doesn't anybody know if there is a general way to use datatypes on a normal page or usercontrol? Isn't there a package or control which can do this?

  • Richard Soeteman 4035 posts 12842 karma points MVP
    Feb 02, 2010 @ 08:59
    Richard Soeteman
    0

    Hi Jeroen,

    I think you should download the sourcecode of Blog4Umbraco and see what they did with the create post usercontrol. The loop through the properties and generate the controls based on that, so I think it's a good start.

    Cheers,

    Richard

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 08, 2010 @ 14:59
    Jeroen Breuer
    0

    Eventually I wrote my own code instead of using existing datatypes because I needed to add to some extra business logic. If I ever need to use default datatypes on a page or usercontrol I'll look at the sourcecode of Blog4Umbraco. Thanks again Richard!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Feb 11, 2010 @ 14:35
    Jeroen Breuer
    0

    Is the Blog4Umbraco sourcecode available? At codeplex I can only find the package. I want to look at the source code because I want to use the TinyMCE datatype on my custom control.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 18, 2010 @ 08:59
    Jeroen Breuer
    0

    Does somebody know where in the Umbraco Source code I have to look for the part where datatypes are loaded into a page (contenttype). If I look at EditMember.aspx or editMedia.aspx it only show the default controls (like the passwordChanger in the member section), but I can't find the place where the extra datatypes are loaded which are defined in the contenttype. If I know where it's done I might be able to figuere out how I can place datatypes on a custom page. I'd still like to place the TinyMCE editor on a custom page.

  • Comment author was deleted

    Mar 18, 2010 @ 09:12

    Hi Jeroen,

    Sure the sourcecode for Blog4Umbraco is availalbe, just download the latest changeset

    http://blog4umbraco.codeplex.com/SourceControl/list/changesets

  • Comment author was deleted

    Mar 18, 2010 @ 09:13

    Hi Jeroen,

    A good way to see how you can load datatypes in a usercontrol is to take a look at the autoform code.

    The code should be in the umbraco extensions project on codeplex: http://umbracoext.codeplex.com/SourceControl/list/changesets

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 18, 2010 @ 09:50
    Jeroen Breuer
    0

    Thanks for the source code Tim. I've looked at the CreatePost.ascx page and it might be helpfull, but where is this usercontrol used? I'd like to see an example how this page looks like.

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 18, 2010 @ 10:21
    Jeroen Breuer
    0

    The CreatePost.ascx is usefull, but it displays all the datatypes from another document type. What I would like is to be able to load a datatype directly without it being defined on a document type. Does somebody have a sample for that?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 18, 2010 @ 14:34
    Jeroen Breuer
    0

    I've finally been able to add datatypes to a normal page. Here is my sample for the TinyMCE editor:

    Frontpage:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FormatEmail.ascx.cs" Inherits="MikzIntranet.UmbracoExtension.Tree.Member.FormatEmail" %>
    <%@ Register Namespace="umbraco.uicontrols" Assembly="controls" TagPrefix="umb" %>
    
    <umb:TabView ID="TabViewDetails" runat="server" Width="552px" Height="692px"/>
    <asp:PlaceHolder ID="blogpostControls" runat="server"></asp:PlaceHolder>

    Backend:

    public partial class FormatEmail : System.Web.UI.UserControl
        {
            private umbraco.editorControls.tinyMCE3.TinyMCE _tinymce = null;
            public TabPage managementTab;
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (_tinymce != null)
                {
                    if (_tinymce.config["umbraco_toolbar_id"] != null)
                    {
                        _tinymce.config.Remove("umbraco_toolbar_id");
                    }
                    _tinymce.config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab01layer_menu_sl"));
                }
            }
    
    
            protected override void OnInit(EventArgs e)
            {
                base.OnInit(e);
    
                managementTab = TabViewDetails.NewTabPage("Beheer");
                managementTab.Controls.Add(blogpostControls);
    
                DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87);
                _tinymce = (umbraco.editorControls.tinyMCE3.TinyMCE)d.DataType.DataEditor;
                blogpostControls.Controls.Add(_tinymce);
            }
        }

    The only thing I dont understand is the following line:

    _tinymce.config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab01layer_menu_sl"));

    Without this the TinyMCE editor doesn't work but what does it do and why?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 16, 2010 @ 09:56
    Jeroen Breuer
    0

    Time to kick this topic again :). I still don't understand what this does:

    _tinymce.config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab01layer_menu_sl"));

    Also now I want to add 2 TinyMCE datatypes to a custom section, but I can't get it to work. I'm using the following code:

    if (_smallEditorNL != null)
    {
        //Set the config so the editor can be displayed.
        if (_smallEditorNL.config["umbraco_toolbar_id"] != null)
        {
            _smallEditorNL.config.Remove("umbraco_toolbar_id");
        }
        _smallEditorNL.config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab02layer_menu_sl"));
    }
    
    if (_defaultEditorNL != null)
    {
        //Set the config so the editor can be displayed.
        if (_defaultEditorNL.config["umbraco_toolbar_id"] != null)
        {
            _defaultEditorNL.config.Remove("umbraco_toolbar_id");
        }
        _defaultEditorNL.config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab02layer_menu_sl"));
    }

    This is supposed to make sure both editors work in the custom section, but now I the buttons are double:

    Some Umbraco core member know how this works and what I should do to add 2 TinyMCE editors to a custom section? Thanks.

    Jeroen

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 20, 2010 @ 09:40
    Jeroen Breuer
    0

    Anyone knows how this can be done? Thanks.

    Jeroen

  • Alex Campbell 47 posts 69 karma points
    Oct 06, 2010 @ 18:17
    Alex Campbell
    0

    Jeroen, did you fix this? Did you try seperating the two fields onto seperate tabs?

    My problem is that I can't get the buttons on the correct tab...

    Cheers,

    Alex

  • Vincent Hendriks 13 posts 35 karma points
    Oct 07, 2010 @ 10:07
    Vincent Hendriks
    1

    Thanks for this post. It helped me a lot.

    The only thing that umbraco_toolbar_id does is point to where tinymce has to create it's toolbar.

    I also ran into the problem when using more then 1 tinymce edit field on 1 page and fixed it.

    The problem you are having is probably that you've pointed it to the same element for both tinymce edit fields.

    The trick is to to create a unique element for each tinymce edit field inside the menubar. In my case I'm using an UmbracoPanel, but it'll probably work exactly the same when using a TabView.

    Here's the code i've used.

    The first edit field:


       panel.Menu.NewElement("div", "tinyMCEMenu1", "tinymceMenuBar", 0);
       DataTypeDefinition dataTypeDefinition1 = DataTypeDefinition.GetDataTypeDefinition(2318);
       umbraco.editorControls.tinyMCE3.TinyMCE tinymce1 = (umbraco.editorControls.tinyMCE3.TinyMCE)dataTypeDefinition1.DataType.DataEditor;
       tinymce1.config.Add("umbraco_toolbar_id", "tinyMCEMenu1");
       plhDescription.Controls.Add(tinymce1);

     And the second edit field:

       panel.Menu.NewElement("div", "tinyMCEMenu2", "tinymceMenuBar", 0);
       DataTypeDefinition dataTypeDefinition2 = DataTypeDefinition.GetDataTypeDefinition(2318);
       umbraco.editorControls.tinyMCE3.TinyMCE tinymce2 = (umbraco.editorControls.tinyMCE3.TinyMCE)dataTypeDefinition2.DataType.DataEditor;
       tinymce2.config.Add("umbraco_toolbar_id", "tinyMCEMenu2");
       plhDescription.Controls.Add(tinymce2);

     (I've created a custom datatype definition so that's why i'm using GetDataTypeDefinition with the ID 2318)

    Anyhow, all is fine for me now, just wanted to share my code in case it can help other people.

    Best Regards,

    Vincent

  • Alex Campbell 47 posts 69 karma points
    Oct 07, 2010 @ 13:19
    Alex Campbell
    0

    Thanks Vincent

    I was using Jeroen's code (final post on page 1) but I've removed this from the Page_Load:

    if (_tinymce != null)
               
    {
                   
    if (_tinymce.config["umbraco_toolbar_id"] != null)
                   
    {
                        _tinymce
    .config.Remove("umbraco_toolbar_id");
                   
    }
                    _tinymce
    .config.Add("umbraco_toolbar_id", string.Concat(TabViewDetails.ClientID, "_tab01layer_menu_sl"));
               
    }

    Then adjusted yours and it works a treat!

    Thanks,

    Alex

  • Jacob 39 posts 88 karma points
    Nov 24, 2010 @ 14:35
    Jacob
    0

    Im trying to get this to work with the ContentPicker.

    I got this so far:

    DataTypeDefinition dataTypeDefinition1 = DataTypeDefinition.GetDataTypeDefinition(1038);
    umbraco.controls.ContentPicker mediaPicker = (umbraco.controls.ContentPicker)dataTypeDefinition1.DataType.DataEditor;

    mediaPicker.AppAlias = "media";
    mediaPicker.TreeAlias = "media";

    PlaceholderMediaPicker.Controls.Add(mediaPicker);

     

    1038 does not work, and I dont know how to find the correct id. I want this to work on whatever installation it is run at, so why is the id (in this case 1038) hardcoded in all examples.. How do you find the correct id?

    Does the rest of what im doing look correct?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 24, 2010 @ 14:38
    Jeroen Breuer
    0

    You can find the id by going to the data types in the developer section and hover over the datatype. At the bottom (in IE) you can see the id. Here the id's are hard coded but I usually store them in web.config so they are easy to update.

    Jeroen

  • Jacob 39 posts 88 karma points
    Nov 24, 2010 @ 14:42
    Jacob
    0

    ok, so you cannot dynamicly get em somehow? it is not a value you can get with the API from the MediaPicker type or somthing?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Nov 24, 2010 @ 14:46
    Jeroen Breuer
    0

    Not that I'm aware of.

    Jeroen

  • Jacob 39 posts 88 karma points
    Nov 24, 2010 @ 14:52
    Jacob
    0

    I think I found where the ids are from in the database.. the weird thing is if I use a ContentPicker like in

    http://www.nibble.be/?p=87

    and I use the correct ID for a ContentPicker then I get the error 

    Unable to cast object of type 'umbraco.editorControls.pagePicker' to type 'umbraco.controls.ContentPicker'

  • Alex Campbell 47 posts 69 karma points
    Nov 24, 2010 @ 14:55
    Alex Campbell
    0

    Hi Jacob

    I may be misunderstanding this but are you trying to dynamically find the nodeid of the Media Picker? If so, couldn't you pull it straight from the database?

    SELECT     TOP (1) umbracoNode.id
    FROM         umbracoNode INNER JOIN
                          cmsDataType ON umbracoNode.id = cmsDataType.nodeId
    WHERE     (umbracoNode.text = 'Media Picker')

    Alex 

  • Jacob 39 posts 88 karma points
    Nov 24, 2010 @ 14:57
    Jacob
    0

     

    Thats what I figured out I could do.. Im not to big a fan of implementing direct calls to the database, rather use the API if its possible.

    But right now im wondering why I get the cast error when I use the id of the ContentPicker.

    I tried implementing simpleeditor, and that works fine, so the code should be in order, but why it thinks the datatype is a pagePicker I do not know.

     

  • Alex Campbell 47 posts 69 karma points
    Nov 24, 2010 @ 15:18
    Alex Campbell
    0

    Agreed, not the most future proof solution but may be the only one.

    I've not heard of a pagePicker...

  • Rob Watkins 369 posts 701 karma points
    Apr 06, 2011 @ 14:42
    Rob Watkins
    0

    I've managed to successfully add the TinyMCE into my custom page using Jeroen's code here, but with a couple of problems - I'm not getting the content picker on inserting a link, or the media picker on inserting an image - I'm getting the standard popups but without any localisation, so they look like:

     

    Am I missing something obvious?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Apr 06, 2011 @ 15:15
    Jeroen Breuer
    0

    Hmm everything works here. Here is a sample I'm using:

    private TinyMCE _editorDefaultContent;

    DataTypeDefinition editorDatatype = DataTypeDefinition.GetDataTypeDefinition(Configuration.EditorId);

    DataTab.Menu.NewElement("div", "tinyMCEMenu1", "tinymceMenuBar", 0);
    _editorDefaultContent = (TinyMCE)editorDatatype.DataType.DataEditor;
    _editorDefaultContent.config.Add("umbraco_toolbar_id", "tinyMCEMenu1");
    PlaceHolderDefaultContent.Controls.Add(_editorDefaultContent);

    _editorDefaultContent.Text = "Some html";

    Jeroen

  • Rob Watkins 369 posts 701 karma points
    Apr 06, 2011 @ 15:29
    Rob Watkins
    0

    Well, I'm not adding the TinyMCE controls to a top menu, but I can't imagine that would be a problem? I'll try adding a toolbar in in case it is that.

    How is the rest of your custom section set up? I have:

    A page inherits from UmbracoEnsuredPage and is a content page for my own master page, which inherits directly from System.Web.UI.MasterPage but is a content page for umbracoPage.Master.

    Make sense?

     

  • Rob Watkins 369 posts 701 karma points
    Apr 06, 2011 @ 17:18
    Rob Watkins
    0

    Could it be a resource reference I'm missing? The dialogs are not styled at all like the ones in the rest of the Umbraco system, and presumably the TinyMCE setup for the media picker and things is done with a script include?

    I would have thought that the Umbraco master page should be including all of that though!

  • MVJ 6 posts 26 karma points
    Jul 01, 2011 @ 14:06
    MVJ
    0

    Rob,

    Could you solve the issue that you mentioned above? Can you please let me know the solution? I am also having the same issue here, media in the editor is not working.

  • Rob Watkins 369 posts 701 karma points
    Aug 04, 2011 @ 10:51
    Rob Watkins
    0

    Hi MVJ, sorry for late reply, I have been on an extended break, I didn't get i working in the end - time was too tight to make perfect integration as important as just some rich text editing, so I used the Yahoo UI rich editor in the end - I find it much nicer to work with than TinyMCE, and my needs were pretty simple.

  • Pasang Tamang 258 posts 458 karma points
    Aug 19, 2011 @ 12:12
    Pasang Tamang
    0

    Hi all

    I'm trying to load Richtext Editior in a user control. But its not rendering anything. Here is my code sample

    html :<asp:PlaceHolder ID="plcs" runat="server"></asp:PlaceHolder>
                DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87);
                _tinymce = (umbraco.editorControls.tinyMCE3.TinyMCE)d.DataType.DataEditor;
    
                if (_tinymce != null)
                {
                    umbraco.uicontrols.TabView tabview = (umbraco.uicontrols.TabView)FindControlRecursive(this.Page.Master, "TabView1");
                    if (_tinymce.config["umbraco_toolbar_id"] != null)
                        _tinymce.config.Remove("umbraco_toolbar_id");
                    _tinymce.config.Add("umbraco_toolbar_id", string.Format("{0}_tab01layer_menu_sl", tabview.ClientID));
                }
                plcs.Controls.Add(_tinymce);

    Plz. anyone help me what I'm missing in my code.

    Thanks

    Pnima

  • Jigs 40 posts 63 karma points
    Sep 01, 2011 @ 03:51
    Jigs
    0

    i follewed the above code but RTE not renderring on the page ............any idea about that ????

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 01, 2011 @ 09:34
    Jeroen Breuer
    0

    Hello,

    Could you please post some of your code so I can see what might be going wrong. Do you get any errors?

    Jeroen

  • Jigs 40 posts 63 karma points
    Sep 23, 2011 @ 07:34
    Jigs
    0

    Hi Jeroen,

    I figure out finally how to render RTE on the edit page of my custom section .... thanx for the code .... but now i want to use uComponent dataType Grid which i defined in my datatype -- developer section .... in the edit page of my custom section any idea how can i use that .....

    Cheers,

    Jigs

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 23, 2011 @ 13:09
    Jeroen Breuer
    0

    Hi Jigs,

    Sorry I haven't added the dataType grid to a custom section yet. However I did use MNTP. Perhaps you can use this sample: http://our.umbraco.org/wiki/reference/code-snippets/use-mntp-on-a-usercontrol.

    Jeroen

  • Jigs 40 posts 63 karma points
    Sep 26, 2011 @ 03:06
    Jigs
    0

    Hi Jeroen,

    Thanx for your help ,,, I tried your example and i got error of type cast.

     

    Unable to cast object of type 'uComponents.Core.DataTypes.DataTypeGrid.DtgDataEditor' to type 'umbraco.cms.businesslogic.datatype.AbstractDataEditorControl'.

     

    Here is my code .....

     

    Am i doing anything wrong ...... any help would be appriciated....

    Thanx,

    Jigs

     

  • Ove Andersen 435 posts 1541 karma points c-trib
    Sep 26, 2011 @ 09:39
    Ove Andersen
    0

    That could be because DTG doesn't derive from AbstractDataEditorControl. :-)

    It derives from: Control, INamingContainer, IDataEditor.

  • Jigs 40 posts 63 karma points
    Sep 27, 2011 @ 00:17
    Jigs
    0

    Hi Ove,

    Thanx for your help ,,,, i will try this and let you know how it works......

    Cheers,

    Jigs

  • Jigs 40 posts 63 karma points
    Sep 27, 2011 @ 05:00
    Jigs
    0

    Hi Ove,

    I tried this one gave me null refrence error ...... any idea why ??? .....any Example would be appriciated ..... thankx

    dtg = (uComponents.Core.DataTypes.DataTypeGrid.DtgDataEditor)((IDataEditor)dg.DataType.DataEditor);

    cheers,

    Jigs

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 27, 2011 @ 10:32
    Jeroen Breuer
    0

    It might be a good idea to have a look at the source code to see how everything works. When I tried using MNTP in a custom section I also didn't know how it worked, but after looking at the source code it was a lot clearer.

    Jeroen

  • Andrew Dyton 2 posts 22 karma points
    Sep 27, 2011 @ 12:07
    Andrew Dyton
    0

     

    Hi all,

    Having some difficulty getting the richtext editor to render from within a user control used as a datatype.

    When I use the code below, I get the textarea rendered in the page, but a javascript error prevents the richtext editor from loading.

    DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87);
    _tinymce = (umbraco.editorControls.tinyMCE3.TinyMCE)d.DataType.DataEditor; if (_tinymce != null) { umbraco.uicontrols.TabView tabview = (umbraco.uicontrols.TabView)this.Page.Master.FindControlR("TabView1"); if (_tinymce.config["umbraco_toolbar_id"] != null) { _tinymce.config.Remove("umbraco_toolbar_id"); } _tinymce.config.Add("umbraco_toolbar_id", string.Format("{0}_tab01layer_menu_sl", tabview.ClientID)); } ph.Controls.Add(_tinymce);

    I get the following javascript error:

    Cannot call method 'appendChild' of null

     

    I've tried a few different approaches to creating the richtext editor, but the only success I've had is to render the richtext editor with its own toolbar and no media library integration, which isn't really suitable for my needs.

    Has anyone had any success in rendering a richtext editor that hooks into the toolbar and is capable of accessing the media library?

    Thanks,

    Andy

     

     

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Sep 27, 2011 @ 13:03
    Jeroen Breuer
    0

    Hello,

    I created a custom datatype which extends the TinyMCE editor. See this package: http://our.umbraco.org/projects/backoffice-extensions/digibiz-email-form-with-tinymce.

    If you give me your email I can send you the source code.

    Jeroen

  • Andrew Dyton 2 posts 22 karma points
    Sep 27, 2011 @ 13:07
    Andrew Dyton
    0

    That'd be very useful, thanks! My email address is: [email protected]

  • Jigs 40 posts 63 karma points
    Sep 28, 2011 @ 01:55
    Jigs
    0

    Hi Andrew,

    Try this source code if yyou want the MCE in the tab with toolbar hooked up with umbraco toolbar ... as it is like umbraco and you can also working media button .... from media liabrary ....

    http://our.umbraco.org/forum/developers/extending-umbraco/17750-Using-tinyMCE-in-custom-section

    Cheers,

    Jigs

     

  • Jigs 40 posts 63 karma points
    Oct 05, 2011 @ 04:34
    Jigs
    0

    Hi Jeroen,

    Finally .... i got it ..... How to render DataType Grid ---- uComponent in custom section ......

    I figure it out from the source code of the uComponent ............... thnaks for good advice ....

    Cheers,

    Jigs

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Oct 05, 2011 @ 08:51
    Jeroen Breuer
    0

    Hi Jigs,

    Great you got it working! Could you please share some pieces of your code so we can learn from it? Thanks.

    Jeroen

  • Jigs 40 posts 63 karma points
    Oct 10, 2011 @ 00:40
    Jigs
    0

    hi Jeroen,

    sorry for late reply, i was off for 3 days from the work.....

    here is the code for working data grid on custom page .... but still i have a problem to store more than 1 record in the grid ..... i only store one record in the grid ..... trying to find the solution of this problem but anyways it render the datatype grid in the custom page so i am happy ....

    i will let you know the perfect solution if i can find the solution of the above problem.

    Cheers,

    Jigs

  • Ove Andersen 435 posts 1541 karma points c-trib
    Oct 12, 2011 @ 14:28
    Ove Andersen
    0

    Sorry for late answer, there’s a lot of work at the moment.

    My first guess from your code examples is that you have a typical viewstate problem where the control in question does not persist through postback.

    You need to recreate the DTG control on every Page_Load to prevent ASP.NET from creating a new instance of the control on every postback. (Which is what it sounds like is happening)

    Try loading the DTG control in Page_Loage  (From the code you posted in your latest post, it looks like you’re already doing this), but also give the control an ID.
    That way, when ASP.NET loads the page after a postback (which is what happens when you press the “Add” button), it finds a control in memory with the same ID as the one you’re recreating in Page_Load.
    ASP.NET will then return the control in memory, instead of creating a new control.

  • MK 429 posts 905 karma points
    Mar 20, 2012 @ 09:04
    MK
    0

    Hi there,

    Great post!

    Im trying to add the uComponent Autocomplete on to my aspx page.

    I managed to render it but need to set the data value for it.

    Does anyone know how to set this up?

    Also, Do I have to use the asp.net script manager or is there another solution for this one? 

    Many thanks

    mkariti

     

     

  • MK 429 posts 905 karma points
    Mar 20, 2012 @ 10:06
    MK
    1

    Ok I got it!

    Just made sure that my aspx page is inherit from the umbraco/masterpages/umbracoDialog.Master which holds all the required scripts .

    That is cool!!!

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 20, 2012 @ 10:09
    Jeroen Breuer
    0

    Don't know if you've seen this wiki, but it's also a good example: http://our.umbraco.org/wiki/reference/code-snippets/use-mntp-on-a-usercontrol

    Jeroen

  • MK 429 posts 905 karma points
    Mar 20, 2012 @ 10:27
    MK
    0

    Hi Jeroen,

    Yes I did but thought that it's not what I was after.

    All I needed is to implement the uComponent Autocomplete field on an aspx page which acts as a popup window.

    Does this looks ok? It is working but not sure if I implemented correctly.

     

                DataTypeDefinition dg = DataTypeDefinition.GetDataTypeDefinition(1191);

                IDataType supplierPicker = dg.DataType;

                supplierPicker.Data.Value = "supplierPicker";

              supplierPicker.DataEditor.Editor.ID = "supplierPickerId";

                myPlaceHolder.Controls.Add(supplierPicker.DataEditor.Editor);

     

     And offcourse made sure that my aspx  inherit from umbraco/masterpages/umbracoDialog.Master

     

    Cheers

    mkariti

     

     

  • MK 429 posts 905 karma points
    Mar 20, 2012 @ 12:53
    MK
    0

    Ok So I got the control on the aspx page, Does anyone know how can I access his values from the c#?

    When adding a new member to the list all that is rendered is as follows:

    <input id="body_body_5551141Button" type="submit" value="Delete" name="ctl00$body$body_5551141Button">
    &nbsp;demo
    <br>
    Cheers
    mkariti
  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 20, 2012 @ 13:06
    Jeroen Breuer
    0

    Hmm maybe something like myPlaceHolder.Controls.FindControl(id) but not sure if that will find it. Perhaps a recursive findcontrol method might work.

    Jeroen

  • MK 429 posts 905 karma points
    Mar 20, 2012 @ 13:44
    MK
    0

    Yes I tried that. For some reason I cant get the items the control stores.

    Regards,

    mkariti

  • Adam Prendergast 33 posts 77 karma points c-trib
    Aug 14, 2012 @ 15:15
    Adam Prendergast
    0

    Great post. I now have a custom check box rendering. What is the best practise for exracting values on save?

     

    As a side note - I have set up a DocumentType that stores all the required DataTypes and referenced them that way.

    var docType = DocumentType.GetByAlias("DocTypeAlias");

    var propType = docType.getPropertyType("PropertyTypeAlias");

    var dataType = propType.DataTypeDefinition.DataType;

    dataType.DataEditor.Editor.ID = propType.Alias;

    var data = propType.DataTypeDefinition.DataType.Data;

    placeholder.Controls.Add(dataType.DataEditor.Editor);

  • Jeffrey Valeroso 40 posts 101 karma points
    Nov 08, 2012 @ 04:40
    Jeffrey Valeroso
    0

    Hello,

    How will I call usercontrol from umbraco.editorControls.userControlGrapper just like the code below.
    Instead of TinyMCE I want to call my custom control?

    Thank you 

     

     DataTypeDefinition dataTypeDefinition = DataTypeDefinition.GetDataTypeDefinition(tinyMCEDataTypeId);

                this._tinymce = (TinyMCE)dataTypeDefinition.DataType.DataEditor;

                this._tinymce.ID = "T1";

                this.panRTE.Controls.Add(this._tinymce);

                this.tpInfo.Menu.NewElement("div", "umbTinymceMenu_" + this._tinymce.ClientID, "tinymceMenuBar", 0);

  • Jerry 23 posts 73 karma points
    Mar 28, 2013 @ 23:24
    Jerry
    0

    I know i am too late for this, but i been spending 3 days to make TinyMce on usercontrol to get working,  still no luck. can some one post me a sample code or email to me please [email protected].

    what i had done, i create a macro load user control with tinymce in it. it fail every time, but it is on the page resource.

    i have no idea.

    please help.

     

  • Jerry 23 posts 73 karma points
    Mar 28, 2013 @ 23:44
    Jerry
    0

    ai-ya wrong timing, happy easter

  • Jerry 23 posts 73 karma points
    Apr 04, 2013 @ 00:48
    Jerry
    0

    Hay yo...

    i found it, there is no shortcut, for the frontend part .

    look here http://www.codeproject.com/Tips/164066/Get-TinyMCE-Value-from-Server-Side-in-ASP-NET-4-0

  • Arjan 9 posts 62 karma points
    Oct 01, 2013 @ 11:27
    Arjan
    0

    I finally got TinyMCE working in a custom section; Umbraco 6.1.5.

    The media picker (insert image) wordks fine. Unfortunally, inserting macro's fails on umbraco.presentation.tinymce3.insertMacro.renderMacro_Click(...).   

    Here is the full working and tested source code. Hope it helps someone.

    C:\MyProject\umbraco\Plugins\VacaturesApplication\EditTinyMCE.aspx

    <%@ Page ValidateRequest="false" Language="C#" MasterPageFile="/umbraco/masterpages/umbracoPage.Master" AutoEventWireup="true" 
        CodeBehind="EditTinyMCE.aspx.cs" Inherits="Website_umbraco.Plugins.MyApplication.EditTinyMCE" %>
    
    <asp:Content ID="Content" ContentPlaceHolderID="body" runat="server">
    
        <umb:UmbracoPanel ID="upnl" runat="server" hasMenu="true" Text="Edit bedrijf">
    
            <umb:Pane ID="pn" runat="server">
    
                <%-- Name --%>
                <umb:PropertyPanel runat="server" Text="Name">
                    <asp:TextBox ID="txtName" runat="server" MaxLength="100" CssClass="guiInputText guiInputStandardSize" />
                </umb:PropertyPanel>
    
                <%-- Description (html) --%>
                <umb:PropertyPanel runat="server" Text="Description">
                    <asp:PlaceHolder runat="server" ID="phDescription" />
                </umb:PropertyPanel>
    
            </umb:Pane>
    
        </umb:UmbracoPanel>
    
    </asp:Content>
    

    C:\MyProject\umbraco\Plugins\VacaturesApplication\EditTinyMCE.aspx.cs

    using System;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using umbraco.cms.businesslogic.datatype;
    using umbraco.editorControls.tinyMCE3;
    using umbraco.uicontrols;
    using Umbraco.Web;
    using Umbraco.Web.UI.Pages;
    
    namespace Website_umbraco.Plugins.MyApplication
    {
        public partial class EditTinyMCE : BasePage
        {
            TinyMCE mceDescription;
    
            protected override void OnInit(EventArgs e)
            {
                // Save button
                ImageButton save = upnl.Menu.NewImageButton();
                save.Click += save_Click;
                save.AlternateText = "Save";
                save.ImageUrl = umbraco.GlobalSettings.Path + "/images/editor/save.gif";
    
                // Init TyniMCE for Description
                InitTinyMCE(ref mceDescription, phDescription);
            }
    
            protected void Page_Load(object sender, EventArgs e)
            {
                if (!IsPostBack)
                {
                    // Load your data from db, disk...
                    // in this example it is loaded from  the session
                    txtName.Text = (string)UmbracoContext.Current.HttpContext.Session["txtName"];
                    mceDescription.Text = (string)UmbracoContext.Current.HttpContext.Session["mceDescription"];
                }
            }
    
            void save_Click(object sender, ImageClickEventArgs e)
            {
                // Save your data to db, disk...
                // in this example it is saved in the session
                Umbraco.Web.UmbracoContext.Current.HttpContext.Session["txtName"] = txtName.Text;
                Umbraco.Web.UmbracoContext.Current.HttpContext.Session["mceDescription"] = mceDescription.Text;
            }
    
            // TODO: move to a generic tools class
            public static void InitTinyMCE(ref TinyMCE control, PlaceHolder ph)
            {
                DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87); // -78 = TinyMCE DataType 
    
                control = (umbraco.editorControls.tinyMCE3.TinyMCE)d.DataType.DataEditor;
                ph.Controls.Add(control);
    
                // Add TinyMCE controls to menu bar
                UmbracoPanel panel = FindParent<UmbracoPanel>(control);
                control.config.Add("umbraco_toolbar_id", panel.Menu.ClientID + "_slh");
                panel.Menu.NewElement("div""umbTinymceMenu_" + control.ClientID, "tinymceMenuBar", 0);
            }
    
            // TODO: move to a generic tools class
            public static T FindParent(Control control)
                where T : class
            {
                while (control != null)
                {
                    control = control.Parent;
                    if (control is T)
                    {
                        return control as T;
                    }
                }
                return null;
            }
        }
    }

     

  • Shaun 248 posts 475 karma points
    Dec 15, 2013 @ 15:23
    Shaun
    0

    I'm getting errors when I try to implement Arjan's solution.

    The problem seems to be in the public static T FindParent method. I get

    "Constraints are not allowed on non-generic declarations."

    Any idea why? I'm duplicating his code. Using Umbraco 6.1.6 and this code is appearing in a codebehind that's being called from the tree.

     

  • Shaun 248 posts 475 karma points
    Dec 15, 2013 @ 15:24
    Shaun
    0

    bug on forum, my question got posted twice.

     

  • Shaun 248 posts 475 karma points
    Dec 15, 2013 @ 15:34
    Shaun
    0

    Sussed it. I just needed to change it to

    public static T FindParent<T>(Control control)

Please Sign in or register to post replies

Write your reply to:

Draft