Copied to clipboard

Flag this post as spam?

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


  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 12, 2010 @ 09:35
    Stefan Kip
    0

    umbraco 4.5 - custom tree and create dialog

    Hi people! :-)

    I'm busy with the 301 URL Tracker, it's not compatible with umbraco 4.5 yet.
    I'm facing one particular problem in my custom Create dialog page, with this markup:

    <input type="hidden" name="nodeType" value="-1"/>

    <asp:Label runat="server" ID="lblMessage" Text="Please select a valid node" Visible="false" style="colorRedfont-size90%font-weightbolddisplayblock;" />
    <b>Select a node:</b>
    <br /><br /><asp:PlaceHolder runat="server" ID="phContentPicker" />

    <!-- added to support missing postback on enter in IE -->
    <asp:TextBox runat="server" style="visibilityhiddendisplaynone;" ID="Textbox1"/>

    <div style="margin-top15px;">
    <asp:Button ID="btnSelect" runat="server" OnClick="btnSelect_Click" style="margin-top14px" Width="90" />
    <em> or </em>  
    <a href="#" style="colorBluemargin-left6px;" onclick="parent.closeModal()"><%= umbraco.ui.Text("cancel") %></a>
    </div>

    I copied this from a blogpost or some other package (don't know anymore) and it works perfectly in 4.0.x.
    The code-behind looks like this:

    public partial class Create301URLTrackerControl : System.Web.UI.UserControl
    {
    ContentPicker cPicker = new ContentPicker();

    protected void Page_Load(object sender, EventArgs e)
    {
    cPicker.ModalWidth = 380;
    cPicker.ModalHeight = 200;
    phContentPicker.Controls.Add(cPicker);

    btnSelect.Text = ui.Text("create");
    }

    protected void btnSelect_Click(object sender, EventArgs e)
    {
    if (Page.IsValid)
    {
    int nodeId;
    if (int.TryParse(cPicker.Value, out nodeId) && cPicker.Value != "-1")
    {
    string returnUrl = umbraco.presentation.create.dialogHandler_temp.Create(
    umbraco.helper.Request("nodeType"),
    0,
    nodeId,
    new Node(nodeId).Name);

    if (string.IsNullOrEmpty(returnUrl))
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refresh301URLTracker""top.reloadCurrentNode();\ntop.closeModal();top.refreshNode();"true);
    else
    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "refresh301URLTracker""top.reloadCurrentNode();\ntop.right.location.href = '" + returnUrl + "';\ntop.closeModal();top.refreshNode();"true);
    }
    else
    lblMessage.Visible = true;
    }
    }
    }

    So I'm using a ContentPicker, which is located in 'umbraco.controls'.
    The problem is the javascript I register with 'Page.ClientScript.RegisterClientScriptBlock()', I'm getting the following errors and don't know the replacements for there javascript methods, can anyone help? :-)

    Sys.ArgumentException: Value must be a DOM element or a text node. Parameter name: element
    This error is thrown inside a ScriptResource.axd (Sys.UI.DomEvent._ensureDomNode)

    top.reloadCurrentNode is not a function
    This error is thrown by the javascript itself. Also top.closeModal() and top.refreshNode() do not work...

    Umbraco.Controls.TreePicker is not a constructor
    This error is thrown in the create.aspx mark-up:
    var mc_ctl00_body_ctl00_ctl00 = new Umbraco.Controls.TreePicker('ctl00_body_ctl00_ctl00','Choose Content','ctl00_body_ctl00_ctl00_ContentIdValue','ctl00_body_ctl00_ctl00_title','/umbraco/dialogs/treepicker.aspx?rnd=15fa7676b6b34c87aa4cf68abb466650&id=-1&treeType=content&contextMenu=true&isDialog=false&app=content',380,200,true,'/umbraco');Sys.Application.initialize();
  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 12, 2010 @ 09:41
    Jeroen Breuer
    0

    Hi Stefan,

    You could try to add the actuall content picker datatype instead of the umbraco.control version. You can read more about it here: http://our.umbraco.org/forum/developers/extending-umbraco/6863-Datatype-on-normal-page-or-UserControl

    This is how you can add a datatype:

    DataTypeDefinition d = DataTypeDefinition.GetDataTypeDefinition(-87);
    _tinymce = (umbraco.editorControls.tinyMCE3.TinyMCE)d.DataType.DataEditor;
    blogpostControls.Controls.Add(_tinymce);

    Jeroen

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 12, 2010 @ 09:43
    Stefan Kip
    0

    The content picker is working fine...

    The only problem is; how can I hide the Create modal dialog in 4.5?

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 12, 2010 @ 09:56
    Jeroen Breuer
    0

    Oops sorry read it a bit too fast :). Unfortunately I can't help you with hiding the create modal in 4.5.

    Jeroen

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 12, 2010 @ 13:44
    Stefan Kip
    0

    At least found this:

    UmbClientMgr.closeModalWindow()

    To close the modal popup :-)

  • Jeroen Breuer 4908 posts 12265 karma points MVP 5x admin c-trib
    Oct 12, 2010 @ 13:59
    Jeroen Breuer
    2

    Maybe another wrong post but I keep trying :). Have you looked at the following:

    BasePage.Current.ClientTools

    With that you can call all the javascript related to the tree. Some usefull methods I've been using:

    //Reload the tree after sorting.
    BasePage.Current.ClientTools.ReloadActionNode(false, true);
    //Close the pop-up and open the details page.
    BasePage.Current.ClientTools
            .ChangeContentFrameUrl(string.Concat("/umbraco/sections/articles/Category/CategoryDetails.aspx?id=", categoryEntity.CategoryId))
            .ChildNodeCreated()
            .CloseModalWindow();
    //Reload the node in the tree on the left and show a speech bubble the data was succesfully saved.
    BasePage.Current.ClientTools
        .SyncTree(Path, true)
        .ShowSpeechBubble(BasePage.speechBubbleIcon.save, "Saved", "The data has been saved succesfully");
    BasePage.Current.ClientTools.CloseModalWindow()

    Hope this helps. I've got all this by looking at the \umbraco\businesslogic\BasePages\ClientTools.cs in the source code.

    Jeroen

  • Stefan Kip 1614 posts 4131 karma points c-trib
    Oct 12, 2010 @ 15:09
    Stefan Kip
    0

    Thanks! You should blog about this! :-)

Please Sign in or register to post replies

Write your reply to:

Draft