I'm fairly new to Umbraco. I've been evaluating v3 for most 2008 (in spare time) and over the last two months have built our company website on v4. Thanks for all the hard work on v4 and for producing an excellent product.
I'm starting to add some of the more advanced features to the website, one being the addition of a download page that emails the user a link back to the actual downloadable resource.
I've got most of this working using a UserControl however I now need to pull the UpLoad File field vlaue from the page and place it in the email!
Can anyone tell me how to access the page fields from a UserControl or how to pass them in via the public properties?
I've search the forum and google but maybe I'm using the wrong terms. All I found was the following posting which asks the same question but with no answers.
An alternative solution, as mentioned by Casey and Morten in the forum post you reference, is to use the API to access the values. I generally use an UmbracoHelper class in my Web Application project for use in my user controls. Thus in your user control you can write:
@codestuff if you find the solution, or if someone else provides the correct solution, can you please remember to mark that post as the solution as this helps others find it quicker and the thread also is marked as resolved.
Using page fields in a C# User control
Hi
I'm fairly new to Umbraco. I've been evaluating v3 for most 2008 (in spare time) and over the last two months have built our company website on v4. Thanks for all the hard work on v4 and for producing an excellent product.
I'm starting to add some of the more advanced features to the website, one being the addition of a download page that emails the user a link back to the actual downloadable resource.
I've got most of this working using a UserControl however I now need to pull the UpLoad File field vlaue from the page and place it in the email!
Can anyone tell me how to access the page fields from a UserControl or how to pass them in via the public properties?
I've search the forum and google but maybe I'm using the wrong terms. All I found was the following posting which asks the same question but with no answers.
http://forum.umbraco.org/yafpostst2295passing-values-to-net-user-controls-from-umbraco.aspx
Thansk in advance for any help and sorry if this turns out to be so obvious!!!
Cheers
Dave
Ha
A little more digging and I found the solution - really I have spent a good 2 days on this! Sorry for the what now seems a silly post to me.
For reference for those like me :-) the solution is as follows
where resFileResource is a page field in the document type.
Cheers
Dave
Good work, that is the way to do it.
Let us know if you run into anything else.
Cheers,
Nik
Hi Dave,
An alternative solution, as mentioned by Casey and Morten in the forum post you reference, is to use the API to access the values. I generally use an UmbracoHelper class in my Web Application project for use in my user controls. Thus in your user control you can write:
This way you can implement error checking and throw explicit exceptions, for examle if the property alias doesn't exist on the current node.
See my blog post here for more, and the source code for my UmbracoHelper class (which includes other helpful methods like this):
http://web-garden.co.uk/2009/3/28/an-update-to-my-umbraco-helper-class.aspx
@codestuff if you find the solution, or if someone else provides the correct solution, can you please remember to mark that post as the solution as this helps others find it quicker and the thread also is marked as resolved.
Great to hear that worked it out.
Peter Gregory
is working on a reply...