Copied to clipboard

Flag this post as spam?

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


  • Ramakrishna 12 posts 32 karma points
    Jul 08, 2010 @ 13:05
    Ramakrishna
    0

    Accessing umbraco fields at server side

    i created a document type "ABC" and i added tab for that as "Aboutustext" and i created one property called

    "Aboutustext" under "Aboutustext"(my tab and property names are same)..

    for that "ABC" doucment i got relative template name "ABC" in that i added textfield (below is code)

     <umbraco:Item field="Aboutustext" runat="server"></umbraco:Item>

    My Question is i want to access this item at server side and i want to know how to make visible true and false

    i searched on net but i didnt get any library if you provide link for propreties available under <umbraco:Item> tag

    it is so help full for me

    tanks in advance.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 08, 2010 @ 13:43
    Dirk De Grave
    0

    Moved topic as it wasn't a forum bug...

    If you need to get hold of a document info in .net code, use

    umbraco.presentation.nodeFactory

    class

    So, if you know the id of the node, use

    umbraco.presentation.nodeFactory.Node currentNode = new umbraco.presentation.nodeFactory.Node(1234);

    or, if you don't know the specific id

    umbraco.presentation.nodeFactory.Node currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent();
    Last code snippet will work out what node is currently being rendered
    If you need a specific property on that document, use
    umbraco.presentation.nodeFactory.Node currentNode = umbraco.presentation.nodeFactory.Node.GetCurrent();
    string property = currentNode.(g)GetProperty("propertyAlias");
    (I always forget whether I need upper-or or lowercase, intellisense will tell)
    Hope this helps.
    Regards,
    /Dirk

  • David Conlisk 432 posts 1008 karma points
    Jul 08, 2010 @ 18:36
    David Conlisk
    1

    I think you'll need that last line to be

    string property = currentNode.GetProperty("propertyAlias").Value;

    otherwise it won't compile - and it's an uppercase G :)

  • dan 29 posts 53 karma points
    Jul 09, 2010 @ 21:51
    dan
    1

    I tried this and it worked.

    <umbraco:Item field="header" runat="server" visible="false" ID="uiheader"></umbraco:Item>

    protected void Page_Load(object sender, EventArgs e)

    {

    uiheader.Visible = true;

    }

     

    Everytime the page loads it will make the Item visible.

    Hope this works.

    Dan

    danielcruger.com

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jul 10, 2010 @ 10:15
    Dirk De Grave
    0

    Ha, nice addition Dan, haven't used it like that before, but seems very efficient, thanks for sharing.

     

    Cheers,

    /Dirk

Please Sign in or register to post replies

Write your reply to:

Draft