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.
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
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:
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.
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.
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.
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.
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)
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
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:
will get you all data about the document with id = 1234
Hope this helps.
Regards,
/Dirk
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
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
From where i can get businesslogic, cms and umbraco assemblies.
They're in the /bin folder of your Umbraco installation.
Oh thnks.then how can i implement it in .cs file following my wanted.
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
Hi Dark,
I cant write the code. if you have enough time then pls give me the code in cs .
Touhid
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
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
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
Hi
Thnks to everybody for some good advice. In my bin folder there is no umbraco assemblies.dll. Is it needed ?
Touhid
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
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:
Can you tell me what was the problem? I have try to many time but can not solve it.
Touhid
Hi Everybody
I have done with my expectation. I saw there was my mistake.
lastly thanks everybody.
Touhid
is working on a reply...