if that renders a number, fetch it trough the prevalues
var colorIdAsString=Umbraco.AssignedContentItem.GetPropertyValue<string>("PuffColor");
var color=Umbraco.GetPreValueAsString(colorIdAsString);
As a sideNode, why are you doing Umbraco.AssignedContentItem? When you call a partialView, you automatically pass the model from the View you are on.
So if your Main view/template and the partialView have the same inherit at the top @inherits Umbraco.Web.Mvc.UmbracoTemplatePage or @inherits Umbraco.Web.Mvc.UmbracoViewPage you can just use Model.GetPropertyValue
Hi Sven
Thanks alot but i still have problem
I have a masterpage from where I call the Partvial View and I wanted to access i from the sub page with another template.
It doesn't work with the Model.GetPropertyValue, so i hade to use
var color=Umbraco.AssignedContentItem.GetPropertyValue("PuffColor");
But i Noticed that I can use item @Umbraco.Field("puffColor")
I still have a problem to convert
var color=Umbraco.GetPreValueAsString(colorIdAsString);
CS1502: The overlay method that best matches Umbraco.Web.UmbracoHelper.GetPreValueAsString (int) has some invalid arguments
/Christina
Problem getting value from radiobuttonlist with Umbraco.GetPreValueAsString
Hi can someone see whats wrong with my code
I have this in a PartialView
I revice an error
CS1502: The overlay method that best matches int.Parse (string) has some invalid arguments
Thanks Christina
Hey Christina
In your first line you are asking to transform the value in the "PuffColor" property into a IPublishedContent
Next you are asking to retrieve the string of the prevalue base on a numerical string value.
An IPublishedContent is not a numerical string, it is an object.
Depending on your umbraco version, you can get the string value immediatly
Try rendering the value of the puffcolor straight away
if that renders a number, fetch it trough the prevalues
As a sideNode, why are you doing
Umbraco.AssignedContentItem
? When you call a partialView, you automatically pass the model from the View you are on. So if your Main view/template and the partialView have the same inherit at the top@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
or@inherits Umbraco.Web.Mvc.UmbracoViewPage
you can just use Model.GetPropertyValueHi Sven Thanks alot but i still have problem I have a masterpage from where I call the Partvial View and I wanted to access i from the sub page with another template. It doesn't work with the Model.GetPropertyValue, so i hade to use var color=Umbraco.AssignedContentItem.GetPropertyValue("PuffColor"); But i Noticed that I can use item @Umbraco.Field("puffColor") I still have a problem to convert
CS1502: The overlay method that best matches Umbraco.Web.UmbracoHelper.GetPreValueAsString (int) has some invalid arguments /Christina
Does
Model.Content.GetPropertyValue
work? (if not, show me the line that start with @inherits in the template where you are placing this code)try
var color=Umbraco.GetPreValueAsString(Convert.ToInt32(colorIdAsString));
Hi Sven Many Thanks I have solved it /C
is working on a reply...