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
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; } }
This should work. Just tried it out in a test solution
namespace test { publicclasshello { publicstring SiteUrl { get { return _hello; } set { _hello = value; } }
privatestring _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.
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:
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:
Any ideas?
Thanks
Eddie
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
For the type, try hello.test (i.e. [namespace].[class])
Then try the browse properties and it should appear.
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.
Bijesh, I'm afraid I stil get the error.
Thanks
Eddie
Eddie,
What version of umbraco and .net framework are you using?
Regards
Ismail
This should work. Just tried it out in a test solution
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
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
Glad you got it working :)
is working on a reply...