{"action":"closed","issue":{"url":"https://api.github.com/repos/mikeedwards83/Glass.Mapper/issues/358","repository_url":"https://api.github.com/repos/mikeedwards83/Glass.Mapper","labels_url":"https://api.github.com/repos/mikeedwards83/Glass.Mapper/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/mikeedwards83/Glass.Mapper/issues/358/comments","events_url":"https://api.github.com/repos/mikeedwards83/Glass.Mapper/issues/358/events","html_url":"https://github.com/mikeedwards83/Glass.Mapper/issues/358","id":384462967,"node_id":"MDU6SXNzdWUzODQ0NjI5Njc=","number":358,"title":"NullReferenceException with WebForms in Glass 5.2.13","user":{"login":"fafinsch","id":8985323,"node_id":"MDQ6VXNlcjg5ODUzMjM=","avatar_url":"https://avatars2.githubusercontent.com/u/8985323?v=4","gravatar_id":"","url":"https://api.github.com/users/fafinsch","html_url":"https://github.com/fafinsch","followers_url":"https://api.github.com/users/fafinsch/followers","following_url":"https://api.github.com/users/fafinsch/following{/other_user}","gists_url":"https://api.github.com/users/fafinsch/gists{/gist_id}","starred_url":"https://api.github.com/users/fafinsch/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fafinsch/subscriptions","organizations_url":"https://api.github.com/users/fafinsch/orgs","repos_url":"https://api.github.com/users/fafinsch/repos","events_url":"https://api.github.com/users/fafinsch/events{/privacy}","received_events_url":"https://api.github.com/users/fafinsch/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-11-26T18:50:21Z","updated_at":"2018-12-17T15:30:49Z","closed_at":"2018-12-17T15:30:49Z","author_association":"NONE","body":"Dear Glass-Team\r\n\r\nI get a `NullReferenceException` in the Class `WebFormsContext`:\r\nThe variable `parent` is `null `in my case: \r\n\r\n```csharp\r\n        public Item GetDataSourceItem(Control control)\r\n        {\r\n            var path = string.Empty;\r\n\r\n            if (control != null)\r\n            {\r\n                WebControl parent = control.Parent as WebControl;\r\n                if (parent == null)\r\n                    path = string.Empty;\r\n                path = parent.DataSource;\r\n\r\n            }\r\n            if (path.HasValue())\r\n            {\r\n                return SitecoreService.Database.GetItem(path);\r\n            }\r\n            return null;\r\n        }\r\n```\r\n\r\nI'm not quite sure, but I guess it should be something like:\r\n\r\n```csharp\r\n        public Item GetDataSourceItem(Control control)\r\n        {\r\n            var path = string.Empty;\r\n\r\n            if (control != null)\r\n            {\r\n                WebControl parent = control.Parent as WebControl;\r\n                // --- Fix start ---\r\n                if (parent != null)\r\n                    path = parent.DataSource;\r\n                // --- Fix end ---\r\n\r\n            }\r\n            if (path.HasValue())\r\n            {\r\n                return SitecoreService.Database.GetItem(path);\r\n            }\r\n            return null;\r\n        }\r\n```\r\n\r\nKind Regards\r\nMarco\r\n"}}
{"actor":{"display_login":"mikeedwards83"}}