Well, I got no answer, so I don't know of any "clean" way... I ended up doing it via SQL...
select varcharValue from umbracoContentVersion a
inner join umbracoPropertyData b on b.versionId = a.id
inner join cmsPropertyType c on c.id = b.propertyTypeId
where [current] = 1 and [text] = 'Home' and [alias] = 'adminID'
This seems to work for me for now, marking as solution, but even though this works I would like a more elegant way of doing it.
It's rare you need to diving for data with direct SQL requests to the dB...
When you say c# 'web form' - do you mean .net WebForms approach to building templates? Eg .aspx pages and masterpages? Support for WebForms has been dropped in V8...
..or...
Do you mean a form in a partial view that your trying to read the value after posting...
If you can describe more of what you have codewise and are trying to achieve, then suspect there will be a less murky way we can find to achieve it!
Yes, a .Net C# WebForm. I access it with an Ajax post to do behund-the-scenes stuff and I want to use a property value in Home. Is there a way to reference the Home Model from an outside .Net C# WebForm?
And post your model here - you would have access to the usual Umbraco Helpers inside the API Controller, so easy to pull back content from Umbraco - and write any c#-stuff you need to do in background...
or if it MUST be a .net webforms aspx form and this is separate from Umbraco - you could have an UmbracoApiController that the Webforms project posts to, to retrieve data from Umbraco.
or (and I haven't tried this) if you have the Core + Web Nuget packages installed in a separate class library project - your WebForms project could reference this and the Umbraco connection string, you could create a service to use the Umbraco Helpers... to be your gateway to Umbraco content.
Can I access a model's property from a Web Form?
Ok, so I can access a model's property with @Model.Value("propertyName")
My new challenge is... I have a C# Web Form and I want to access a model property I added, is this possible?
For testing purposes, I added a property AdminID of type Umbraco.TextBox and I gave it a value of 1 on my Document Type "Home."
On my template I access the model:
And I get an alert box with a 1 in it. Everything is fine... Now I want to access this value from a C# Web Form. Is this possible?
Well, I got no answer, so I don't know of any "clean" way... I ended up doing it via SQL...
This seems to work for me for now, marking as solution, but even though this works I would like a more elegant way of doing it.
Any advice?
Hi Edgar
It's rare you need to diving for data with direct SQL requests to the dB...
When you say c# 'web form' - do you mean .net WebForms approach to building templates? Eg .aspx pages and masterpages? Support for WebForms has been dropped in V8...
..or...
Do you mean a form in a partial view that your trying to read the value after posting...
If you can describe more of what you have codewise and are trying to achieve, then suspect there will be a less murky way we can find to achieve it!
Regards
Marc
Yes, a .Net C# WebForm. I access it with an Ajax post to do behund-the-scenes stuff and I want to use a property value in Home. Is there a way to reference the Home Model from an outside .Net C# WebForm?
Hi Edgar
Ok, intriguing!
I'd probably create an UmbracoApiController
https://our.umbraco.com/Documentation/Reference/Routing/WebApi/
And post your model here - you would have access to the usual Umbraco Helpers inside the API Controller, so easy to pull back content from Umbraco - and write any c#-stuff you need to do in background...
or if it MUST be a .net webforms aspx form and this is separate from Umbraco - you could have an UmbracoApiController that the Webforms project posts to, to retrieve data from Umbraco.
or (and I haven't tried this) if you have the Core + Web Nuget packages installed in a separate class library project - your WebForms project could reference this and the Umbraco connection string, you could create a service to use the Umbraco Helpers... to be your gateway to Umbraco content.
will get you a list of the sites at the root of your Umbraco site, and presumably where your homepage lives, or
would get you a specific page, if you post the id of the homepage to your WebForm...
regards
Marc
is working on a reply...