0
votes

I am getting the following error:

The type or namespace name 'GetPreValueAsString' does not exist in the namespace 'Umbraco' (are you missing an assembly reference?)

My code snippet where this error occurs is:

foreach (var member2 in ApplicationContext.Current.Services.MemberService.GetAllMembers().OrderBy(member2 => member2.Name)){
    var codeTheme = Umbraco.GetPreValueAsString(member2.GetValue<int>("codeTheme"));
    <p>@codeTheme</p>
}

I am using the latest version of Umbraco, I think it is because I need @using Umbracomagicmissingreference at the top of the page, but I have no idea which one is missing.

I have a dropdown list in the member area which I am trying to get the text values from so I can create a form that has these values.

Thank-you

1
Can you post the full view please? Is the view using a custom model, or an Umbraco one?Tim
I found changing the line to umbraco.library.GetPreValueAsString(member2.GetValue<int>("codeTheme") looped through the members and output their chosen option. My issue is I want to loop through all the available options in the drop down list.Ginger Squirrel
So you want to get all of the possible pre-values for a given list?Tim
Yes I do, I thought fixing the above issue would get me closer but is hasn't really...Ginger Squirrel
Found it: XPathNodeIterator iterator = umbraco.library.GetPreValues(1124); iterator.MoveNext(); XPathNodeIterator preValues = iterator.Current.SelectChildren("preValue", ""); <ul> @while (preValues.MoveNext()) { string preValue = preValues.Current.Value; <li>@preValue</li> } </ul>Ginger Squirrel

1 Answers

0
votes

I found how to fix this, I changed the following line:

var branch = Umbraco.GetPreValueAsString(member2.GetValue<int>("codeTheme"));

to

var codeTheme = umbraco.library.GetPreValueAsString(member2.GetValue<int>("c‌​odeTheme")