You should be able to get a reference to the current IPublishedContent like so:
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current); var nodeId = int.Parse(HttpContext.Current.Request.QueryString["id"]); var currentNode = umbracoHelper.TypedContent(nodeId);
// Get fields from node var propertyValue = currentNode.GetPropertyValue<string>("hello");
// Not entirely sure if the UmbracoHelper has got a corresponding method for this. Also not sure if IPublishedContent's alias property is called "Alias" or "NodeTypeAlias" or some such :-) var propertyAlias = library.GetPropertyTypeName(currentNode.Alias, "hello");
The usercontrol is loaded 4 times when the document is rendered in the backoffice, and I want to be able to see the name and alias on the corresponding property each time the usercontrol is loaded e.g. in the page load method via the "object sender" parameter.
Getting the Name or Alias on property from UserControl
Hi There!
I have created a datatype "MyDataType" of the type "Umbraco Usercontrol Wrapper" which wraps a usercontrol called "MyUserControl.ascx".
On a document type i have added a property with the name "Hello" and alias "hello" of the type "MyDataType".
Is it in anyway possible to get the alias and name of the property from the codebehind when the usercontrol MyUserControl is loaded?
This is Umbraco 6.1.6
Thanks in advance!
Hi Emil,
You should be able to get a reference to the current IPublishedContent like so:
Let me know how this behaves.
All the best,
Bo
Hi Bo!
I am not sure, but isn't it necessary to know the name of the property in your suggestion?
I may be wrong :) ?
Hi Emil,
Yes, it's necessary to know the property alias using my code example. I take that wasn't what you needed? :-D
No :)
Let's say I have 4 properties on the same document all of 'MyDataType' type but with different names and aliases:
Name: Property1 - Alias: property1 Name: Property2 - Alias: property2 Name: Property3 - Alias: property3 Name: Property4 - Alias: property4
The usercontrol is loaded 4 times when the document is rendered in the backoffice, and I want to be able to see the name and alias on the corresponding property each time the usercontrol is loaded e.g. in the page load method via the "object sender" parameter.
Does it make any sense :) ?
is working on a reply...