I want to use the properties (and their values) in from an .ascx. I have succesfully added the ascx to the usercontrols-map. After that I pointed to it in a new Macro, but it does not show the public properties I have defined in the .ascx. Can someone explain to me how this is done?
In the macros section, select the macro that points to your ascx.
Then, click the 'browser properties' button (this button only appears after you first select an ascx and save the macro... which you've no doubt done by now).
You should now see all the public properties and can add them as macro parameters with a single click. You will want to double-check that datatypes assigned by umbraco for each parameter.
Then save the macro and you're ready to insert the macro into a template or richtext editor. You'll be prompted to enter the macro parameters now, and their values will be passed to your ascx.
After I have clicked 'browse properties', there are no properties in the popup-window. That is my problem. When I instantiate an object of this control in visual studio I can address through intellisense all the properties. I use no .dll, could this be the problem?
The properties will not be automatically retrieved by umbraco, but you can add them by yourself in the macro and it will work (I have tested it right now)...
Just go to the properties tab in the macro and add them manually. The alias must match then property name and the type should also match
OK, what I have learned so far: when using an assembly, the properties are picked up by Umbraco. Without an assembly for the web user control, one can add the properties manually, just like Thomas explained.
I have placed the macro in a file, I have edited the properties, saved, published - but still the default values from the usercontrol are used.
As I said: in Visual Studio the properties are public and always used by the control when edited in a page.
I suspect my problem has started in Visual Studio; when I just created and tested a new project with a simple web user control in Umbraco all works as expected.
The user control I am trying to use in Umbraco exists in a Visual Studio web application and has for some reason no assembly after I have build the project. The ascx.vb also had two classes defined.
Could it be wiser to redesign the user control to make sure it produces an assembly? Does anyone know when an assembly is produced and when not?
If you have a ascx.vb file you are using cod enehind and you have to upload the dll, just look in the first line of the ascx file (you can post the code here if you want) and see if you are using code behind or not. If you are creating an new ascx and you are choosing not to place the code in a separate file it works like I descrived before. if you are using code behind you have to compile and upload the dll
How to access properties from .ascx
I want to use the properties (and their values) in from an .ascx. I have succesfully added the ascx to the usercontrols-map. After that I pointed to it in a new Macro, but it does not show the public properties I have defined in the .ascx. Can someone explain to me how this is done?
In the macros section, select the macro that points to your ascx.
Then, click the 'browser properties' button (this button only appears after you first select an ascx and save the macro... which you've no doubt done by now).
You should now see all the public properties and can add them as macro parameters with a single click. You will want to double-check that datatypes assigned by umbraco for each parameter.
Then save the macro and you're ready to insert the macro into a template or richtext editor. You'll be prompted to enter the macro parameters now, and their values will be passed to your ascx.
cheers,
doug.
Thanks for your reply.
After I have clicked 'browse properties', there are no properties in the popup-window. That is my problem. When I instantiate an object of this control in visual studio I can address through intellisense all the properties. I use no .dll, could this be the problem?
Fabian
Did you create public properties in your acsx? Visual studio can see all properties, including private propery.
You should have something like:
The properties will not be automatically retrieved by umbraco, but you can add them by yourself in the macro and it will work (I have tested it right now)...
Just go to the properties tab in the macro and add them manually. The alias must match then property name and the type should also match
hth,
Thomas
OK, what I have learned so far: when using an assembly, the properties are picked up by Umbraco. Without an assembly for the web user control, one can add the properties manually, just like Thomas explained.
I have placed the macro in a file, I have edited the properties, saved, published - but still the default values from the usercontrol are used.
As I said: in Visual Studio the properties are public and always used by the control when edited in a page.
I suspect my problem has started in Visual Studio; when I just created and tested a new project with a simple web user control in Umbraco all works as expected.
The user control I am trying to use in Umbraco exists in a Visual Studio web application and has for some reason no assembly after I have build the project. The ascx.vb also had two classes defined.
Could it be wiser to redesign the user control to make sure it produces an assembly? Does anyone know when an assembly is produced and when not?
Thanks,
Fabian
If you have a ascx.vb file you are using cod enehind and you have to upload the dll, just look in the first line of the ascx file (you can post the code here if you want) and see if you are using code behind or not. If you are creating an new ascx and you are choosing not to place the code in a separate file it works like I descrived before. if you are using code behind you have to compile and upload the dll
Thomas
also check out the videos, they'll get you up and running quickly
http://umbraco.org/documentation/videos/for-developers/foundation/using-net-user-controls
oh and build events are very handy for copy all these files
http://blog.leekelleher.com/2008/08/20/setting-up-visual-studio-to-work-with-umbraco/
is working on a reply...