Copied to clipboard

Flag this post as spam?

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


  • Fabian 5 posts 23 karma points
    Jul 24, 2009 @ 11:39
    Fabian
    1

    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?

  • Douglas Robar 3570 posts 4711 karma points MVP ∞ admin c-trib
    Jul 24, 2009 @ 11:42
    Douglas Robar
    3

    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.

  • Fabian 5 posts 23 karma points
    Jul 29, 2009 @ 09:13
    Fabian
    0

    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

  • Peter Dijksterhuis 1442 posts 1722 karma points
    Jul 29, 2009 @ 09:45
    Peter Dijksterhuis
    1

    Did you create public properties in your acsx? Visual studio can see all properties, including private propery.

    You should have something like:

    private string _password;
    public string  Password

    {
          get { return _password; }
          set { _password = value; } 
    }
    HTH,
    PeterD

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 29, 2009 @ 09:51
    Thomas Höhler
    2

    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

  • Fabian 5 posts 23 karma points
    Jul 29, 2009 @ 10:19
    Fabian
    0

    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

  • Thomas Höhler 1237 posts 1709 karma points MVP
    Jul 29, 2009 @ 10:32
    Thomas Höhler
    0

    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

  • anthony hall 222 posts 536 karma points
    Jul 29, 2009 @ 10:56
    anthony hall
    1

    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/

     

Please Sign in or register to post replies

Write your reply to:

Draft