Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Pradip 24 posts 116 karma points
    Jun 27, 2019 @ 17:25
    Pradip
    0

    'Content' does not exist in the namespace 'umbraco' error in Scripting File(Macro) in Umbraco 6.1.6

    Hello,

    I have created Scripting file(.cshtml) and mapped as a Macro to display Google Map on pages but I am getting Errors ("Content does not exist in the namespace 'umbraco' ") related to below line regarding Namespaces or Assembly :

    var page = Umbraco.Content(1000);

    Complete Code are as below :

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        var page = Umbraco.Content(1000);
        var locationList = new List<string>();
        var markerJsonArray ="";    
    <h3>@page.Name</h3>
    
        foreach (var location in page.Children)
        {
            <a href="@location.Url">@location.Name</a>
            <a href="@location.Url">@location.Latitude</a>
            <a href="@location.Url">@location.Longitude</a>
    
            locationList.Add(
                string.Format(
                    @"{{""title"":  ""{0}"", ""position"": new google.maps.LatLng({1}, {2})}}",
                    location.Name,
                    location.Latitude,
                    location.Longitude
                )
            );
    
            markerJsonArray = "[" + string.Join(",", locationList.ToArray()) + "]";
    
        }
    
       <div id="map_canvas" style="height:100%;"></div>
    
    
    
    <script>
            $(document).ready(function () {
    
                var map = new google.maps.Map(document.getElementById('map_canvas'));
    
                var markers = @Html.Raw(markerJsonArray);
    
                if (markers && markers.length > 0) {
                    var bounds = new google.maps.LatLngBounds();
    
                    for (var i = 0; i < markers.length; i++) {
                        var marker = new google.maps.Marker(markers[i]);
                        marker.setMap(map);
                        bounds.extend(marker.getPosition());
                    }
    
                    map.fitBounds(bounds);
                    map.setCenter(bounds.getCenter());
                }       
            });
        </script>
    
    
    }
    

    I have other Scripting Files(.cshtml) and using it as a Macros. All working fine.

    I have installed Umbraco 6.1.6 and rendering engine in WebForms. It's working fine on Mvc engine.

    Could you please help me to resolve this issue.?

    Thanks in advance

    Pradip Raj

Please Sign in or register to post replies

Write your reply to:

Draft