Copied to clipboard

Flag this post as spam?

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


  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 05:00
    Touhid
    0

    How can user control retreive document property

    Hi All

     I am using Umbraco 4.5.2 Currently I am developing a.Net user control and a document ID will be assed to it. So how can I retrieve all its properties by using its id? I know xslt can do this but do not know how user control do it?

    I know the umbraco.presentation.nodeFactory.Node.GetCurrent() is helpfull but i cant do it completely.

    Can any one help me with complete code.

    Thank you

    Touhid

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 07:58
    Dirk De Grave
    0

    Touhid,

    using the nodeFactory is the only way to interact with the published data... So, what do you mean then by 'can't do completely'. Using the nodeFactory.Node class, you should be able to get all info about a document

    GetCurrent() can be used to retrieve the document currently being displayed, but you can also use other ctor to get info about any document.

    For example:

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

    will get you all data about the document with id = 1234

     

    Hope this helps.

    Regards,

    /Dirk

     

     

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 08:33
    Touhid
    0

    Hi Dirk

    Thnks for reply. I have created a Data type usercontrol and i want to see the document type values using this user control data type.Like my document type id is 1231 and has a property alis ' header' and my user control has a textbox. so i want to show the value of header from content section in textbox in content section.

     but i cant intereact between them or how to code in .cs file. like my code is:

    And its give an error when i build it:

     

    pls help me .

     

    Touhid

     

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 08:35
    Dirk De Grave
    0

    Must at least reference some umbraco assemblies before using it in code... :p

    I always include businesslogic, cms and umbraco assemblies, should do fine for you as well.

     

    Cheers,

    /Dirk

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 08:53
    Touhid
    0

    From where i can get businesslogic, cms and umbraco assemblies.

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 05, 2011 @ 08:54
    Stephan Lonntorp
    0

    They're in the /bin folder of your Umbraco installation.

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 08:57
    Touhid
    0

    Oh thnks.then how can i implement it in .cs file following my wanted.

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 09:18
    Dirk De Grave
    1

    Come on, the solution is right in front of you, you've got the node object, just use .GetProperty("propertyAlias").Value.ToString() and use that value to set the .Text property on the textbox.

     

    Cheers,

    /Dirk

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 09:39
    Touhid
    0

    Hi Dark,

    I cant write the code. if you have enough time then pls give me the code in cs .

     

    Touhid

  • Stephan Lonntorp 195 posts 212 karma points
    Jan 05, 2011 @ 09:45
    Stephan Lonntorp
    1

    Touhid,

    if at first you don't succeed, try and try again. Just because Umbraco is Open Source, doesn't mean people will write your code for you.

     

    If you don't know C#, I suggest you try and learn it, buy a book or read blogs, but asking people to code for you, is never going to teach you anything.

     

    //Stephan

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 09:47
    Dirk De Grave
    0

    Just give it a try, the solution is already in previous replies, what else would you need/expect? Don't expect us to write the "entire" solution for you, there's plenty of material available on the interweb including umbraco.tv and numerous blog posts which can be of excellent help.

     

    Cheers,

    /Dirk

  • Jan Skovgaard 11280 posts 23678 karma points MVP 10x admin c-trib
    Jan 05, 2011 @ 09:51
    Jan Skovgaard
    0

    Hi Touhid

    +1 to what the others are saying.

    A little hint when seeing errors like the above where you are missing an assembly reference - sometimes you can right click the code where the red underline is and choose "resolve". Then the missing assembly is automatically being included.

    Happy coding

    /Jan

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 10:15
    Touhid
    0

    Hi

    Thnks to everybody for some good advice. In my bin folder there is no umbraco assemblies.dll. Is it needed ?

    Touhid

  • Dirk De Grave 4541 posts 6021 karma points MVP 3x admin c-trib
    Jan 05, 2011 @ 10:18
    Dirk De Grave
    0

    As Stephan pointed out, the umbraco.dll assembly IS in /bin folder of your umbraco installation, so whatever path you've choosen to install (eg. c:\inetpub\yourwebsiteroot, the path should be c:\inetpub\yourwebsiteroot\bin.

    In there, you'll find the necessary assemblies you need to add to your project before compiling (add as a reference through the 'Add reference' dialog in vs.net)

     

    Cheers,

    /Dirk

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 13:02
    Touhid
    0

    Hi

    That was my mistake. now build is succes but when i click on content node, then it shows:

     Server Error in '/' Application.


    Object reference not set to an instance of an object.

    There is my cs code:

    using

     

    System;

    using

     

    System.Collections;

    using

     

    System.Configuration;

    using

     

    System.Data;

    using

     

    System.Linq;

    using

     

    System.Web;

    using

     

    System.Web.Security;

    using

     

    System.Web.UI;

    using

     

    System.Web.UI.HtmlControls;

    using

     

    System.Web.UI.WebControls;

    using

     

    System.Web.UI.WebControls.WebParts;

    using

     

    System.Xml.Linq;

    using

     

    umbraco.presentation.nodeFactory;

    namespace

     

    UmbracoPositionControl

    {

     

    public partial class UmbracoPositionControl : System.Web.UI.UserControl,

    umbraco.editorControls.userControlGrapper.

    IUsercontrolDataEditor

    {

     

    protected void Page_Load(object sender, EventArgs e)

    {

    }

    #region

     

    IUsercontrolDataEditor Members

     

    public object value

    {

     

    get

    {

     

    return TextBox1.Text;

    }

     

    set

    {

    umbraco.presentation.nodeFactory.

    Node currentNode = new Node(1231);

     

    if (currentNode != null)

    {

     

    string nodename = currentNode.Name;

    TextBox1.Text = nodename.ToString();

    }

     

    else

    {

    TextBox1.Text =

    "touhid";

    }

    }

    }

    #endregion

    #region

     

    IUsercontrolDataEditor Members

     

    object umbraco.editorControls.userControlGrapper.IUsercontrolDataEditor.value

    {

     

    get

    {

     

    return TextBox2.Text;

    }

     

    set

    {

    umbraco.presentation.nodeFactory.

    Node currentNode = new Node(1231);

     

    if (currentNode!=null)

    {

     

    string myValue = currentNode.GetProperty("header").Value;

    TextBox2.Text = myValue.ToString();

    }

     

    else

    {

    TextBox2.Text =

    "posituion";

    }

    }

    }

    #endregion

    }

    }

    Can you tell me what was the problem? I have try to many time but can not solve it.

     

    Touhid

  • Touhid 97 posts 117 karma points
    Jan 05, 2011 @ 13:48
    Touhid
    0

    Hi Everybody

    I have done with my expectation. I saw there was my mistake.

    lastly thanks everybody.

    Touhid

Please Sign in or register to post replies

Write your reply to:

Draft