asked    Martha     2018-10-12       c#       19 view        1 Answer

[SOLVED] Umbraco getpropertyvalue does not work on live

I have a helper method that works perfectly on local, however does not want to work on dev server. I used all sorts of logs to find out where the problem lies. It does get the current node and the homepage as well, however when it tries to use the GetPropertyValue<Dictionary<string, string>> it comes back as null.

Error message System.NullReferenceException: Object reference not set to an instance of an object. as I am trying to use this value later down the line.


            var helper = new UmbracoHelper(UmbracoContext.Current);
            var homepage = helper.TypedContent(UmbracoContext.Current.PageId).AncestorOrSelf(1);
            var test = homepage.Children.First(x => x.DocumentTypeAlias == "test");
            Dictionary<string, string> testDict = test.GetPropertyValue<Dictionary<string, string>>("testOptions");

Any ideas?

It finds everything even test node, but testDict is null

  1 Answer  

        answered    Sylvia     2018-10-12      

Off the top of my head, it could be one of the following:

  • The property isn't on the live site node, check the doctype to make sure the property exists, it could also be that there's a typo in the field alias on live, or the field alias is different
  • There is is a property converter that handles the conversion that hasn't been deployed to live

Check both of those to see if that's the issue. If that's not it, just get the value of the field as a string and see what's in there, is the field empty, or is there something in there?

Your Answer

 2018-10-12         Philip

How to load Razor partial view in jQuery without using MVC?

I am working on a Umbraco 7 project started without MVC implemented. I try to implement a loading without page refresh. I am stuck now because I need some Razor code to get Umbraco information but I need jQuery to refresh without page refresh.Here my code:$(function () { $.ajaxSetup({ cache: false }); $('#filterButton').click(function(){ $('#content').html(@Html.Partial("~/Views/Partials/Preferences.cshtml")); }) });I tried with .load()with .html using @Html.Action,@Html.Partial etc, but nothing ...
 c#                     2 answers                     99 view
 2018-10-12         Asa

Populate Umbraco content form with Javascript

I trying to create a custom property editor for Umbraco 7 that talks to an external web service, retrieves some data then populates a number fields in the form with the data it's retrieved. I've tried doing this with the following simple code:$("#textbox_id").val("new value");This does indeed populate the correct field with the correct data. However if I save and reload the form the data has not been updated and value returns to it's original value.Any suggestions? The problem is that you are using jQuery to update the input field directly in the DOM. The backoffice of U...
 javascript                     1 answers                     0 view
 2018-10-12         Gordon

Set date for Umbraco date picker using jQuery

Am creating a button for an Umbraco back-end content editing page that will retrieve a load of data from another database and auto-populate a few of the fields. However some of the fields use the Umbraco datepicker. I can change the value of the text box but when I click to view the datepicker calendar, it has the wrong date selected. How can I set the date of the datpicker so it matches what's in the text box rather than just the change what's in the textbox?Thanks Think I've got it. Once change value of textbox call .change() on the text box and this will update the da...
 jquery                     1 answers                     1 view