Search code examples
dotvvm

DotVVM Markup Conrtrol Property Not Returned


I'm working on authoring a DotVVM Markup Control. This control has one link label that may be dynamic, and so I have a property for it in my code-behind file.

Markup

<td class="navigation_unselected"><a href="~/Members.aspx?TABLE=MEMINFO" class="Navigation_Text">{{controlProperty: MemberKey}}&nbsp;LIST</a></td>

Code Behind

        public string MemberKey
        {
            get { return (string)GetValue(MemberKeyProperty); }
            set { SetValue(MemberKeyProperty, value); }
        }
        public static readonly DotvvmProperty MemberKeyProperty
            = DotvvmProperty.Register<string, MainNavigationControl>(c => c.MemberKey, "Member");

The problem is that when I run the page, the property seems to return null or empty, and the link text is only "LIST". The default value "Member" is not returned. I am not an expert in KnockoutJS, but the generated HTML seems fairly straightforward:

Rendered HTML

<a href="/ImpactProDevDotVVM/Members.aspx?TABLE=MEMINFO" class="Navigation_Text">
<!-- ko text: $control.MemberKey -->
<!-- /ko -->
&nbsp;LIST</a>

I have been working on this for hours, and I am not sure what the problem with this code is. When I simply put the word "MEMBER" in the markup, it works, but the requirement is that it be dynamic with a default.

Can anyone see where I've gone wrong here?


Solution

  • It seems that the problem was with the way the KnockoutJS was being generated, and the implicit <tbody> added by the browser. The solution was to add an explicit <tbody> around my entire table. I was pointed in this direction by a similar error here: Knockout Error: Cannot find closing comment tag to match