I'm running the razor code below in a .cshtml file (it's a simplified version of something more complex that I need to achieve), but the renderTestB
helper does not seem to execute.
@renderTestA("test string 1", "test string 2");
@helper renderTestA(string input1, string input2)
{
<div>
@renderTestB(input1)
@renderTestB(input2)
</div>
}
@helper renderTestB(string input)
{
<p class="test">@input</p>
}
Why is this? And is there another way of achieving what I'm trying to do?
I realise I could duplicate the paragraph code within the renderTestA
helper, but would obviously prefer a re-usable code solution.
does not seem to execute
do you mean you're not seeing the result you want? maybe there's something else wrong, since this is not your actual code it's hard to know – JamieD77@
sign that should have prefixed the function call inside a code block. Feel somewhat silly now. But at least you've taught me that helpers can indeed be nested, in addition to pointing me in the direction of my coding mistake! – lozz