Copied to clipboard

Flag this post as spam?

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


  • Eddie Foreman 215 posts 288 karma points
    Aug 23, 2010 @ 16:26
    Eddie Foreman
    0

    Custom Control Macro Properties

    Hi All,

    First, sorry for all the topics today.  I've a class that I need to load into a macro.  So that the user can edit the public methods.  I could not get the properties to appear and so as a test to isolate the problem, I used the following:

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;

    namespace hello
    {
    public class test
    {
    public string SiteUrl
    {
    get { return _hello; }
    set { _hello = value; }
    }

    private string _hello = "hello Umbraco :-)";
    }
    }

    The dll is hello.dll, so in the .Net Custom Control macro fields.  Assembly is set to hello and type to test.  I get the error:

    Error reading hello

    System.NullReferenceException: Object reference not set to an instance
    of an object.
    at umbraco.developer.assemblyBrowser.Page_Load(Object sender,
    EventArgs e) in
    d:\TeamCity\buildAgent\work\7380c184e9fcd3ea\umbraco\presentation\umbraco\developer\Macros\assemblyBrowser.aspx.cs:line
    60

    Any ideas?

    Thanks

    Eddie

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Aug 23, 2010 @ 16:54
    Ismail Mayat
    1

    Your class needs to inherit from System.Web.UI.UserControl or if the macro is going to be based on .net custom control you need to inherit from 

    • System.Web.UI.Control
    • System.Web.UI.WebControl

  • Bijesh Tank 192 posts 420 karma points
    Aug 23, 2010 @ 17:47
    Bijesh Tank
    0

    For the type, try hello.test (i.e. [namespace].[class])

    Then try the browse properties and it should appear.

  • Eddie Foreman 215 posts 288 karma points
    Aug 23, 2010 @ 18:43
    Eddie Foreman
    0

    Hi Ismail and Bijesh

    Thanks for your replies.

    Ismail, have tried to inherit from System.Web.UI.WebControls, but the same error appears.  Not sure on how I would  inherit from both System.Web.UI.Control and System.Web.UI.WebControl.  

    namespace hello
    {
    public class hello : System.Web.UI.UserControl
    {
    public string SiteUrl
    {
    get { return _hello; }
    set { _hello = value; }
    }

    private string _hello = "hello Umbraco :-)";
    }
    }

    Bijesh, I'm afraid I stil get the error.

    Thanks

    Eddie

  • Ismail Mayat 4511 posts 10090 karma points MVP 2x admin c-trib
    Aug 24, 2010 @ 10:02
    Ismail Mayat
    0

    Eddie,

    What version of umbraco and .net framework are you using?

    Regards

    Ismail

  • Bijesh Tank 192 posts 420 karma points
    Aug 24, 2010 @ 10:37
    Bijesh Tank
    0

    This should work. Just tried it out in a test solution

    namespace test
    {
        public class hello
        {
            public string SiteUrl
            {
                get { return _hello; }
                set { _hello = value; }
            }

            private string _hello = "hello Umbraco :-)";
        }
    }

    And then setting the Assembly to the name of the compiled dll (minus the .dll extension) and the Type set to test.hello. Make sure to save the macro first when you have edited the assembly and type fields, then browse properties.

    This post may also help http://our.umbraco.org/forum/templating/templates-and-document-types/6803-How-to-connect-a-custom-control-to-a-macro,-newbie-question

  • Eddie Foreman 215 posts 288 karma points
    Aug 24, 2010 @ 11:33
    Eddie Foreman
    0

    Hi Guys

    Interesting, not changed a thing and can now load on the control properties using hello.hello on the test class.

    Must be down to a good nights sleep : -)

    Thanks again to you both

    Eddie

  • Bijesh Tank 192 posts 420 karma points
    Aug 24, 2010 @ 11:36
    Bijesh Tank
    0

    Glad you got it working :)

Please Sign in or register to post replies

Write your reply to:

Draft