Copied to clipboard

Flag this post as spam?

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


  • Dominic Pettifer 51 posts 50 karma points
    May 05, 2009 @ 13:20
    Dominic Pettifer
    0

    Getting current doc ID from custom 'DataType' control?

    I have set up a custom DataType by way of a UserControl that implements 'IUsercontrolDataEditor', and I am trying to retrieve the ID of the currently selected Document/Node that the usercontrol appears on.

    If I'm writing a regular UserControl to be used as a Macro for the frontend I normally use...

    [code]Node currentPage = Node.GetCurrent();[/code]

    But when used in a custom DataType it throws a NullReferenceException - Object reference not set to an instance of an object. Here is the code I'm using...

    [code]public partial class ConfigureAdmins : System.Web.UI.UserControl, IUsercontrolDataEditor
    {
    protected void Page_Load(object sender, EventArgs e)
    {
    Node currentPage = Node.GetCurrent();
    }

    public object value
    {
    get { return null; }
    set { }
    }
    }[/code]

    What am I doing wrong? Cheers!

  • Dominic Pettifer 51 posts 50 karma points
    May 05, 2009 @ 13:27
    Dominic Pettifer
    0

    Doh! It seems I should try searching existing umbraco forum threads more. I found I can use...

    [code]int nodeId = Int32.Parse(Request.QueryString["id"]);[/code]

    ...as the ID gets passed to the iframe as a querystring parameter.

Please Sign in or register to post replies

Write your reply to:

Draft