Access ViewContext in Razor Assistant

I have a helper method:

@helper Message(Func<object, object> markup) { <tr class="message"> <td width="100%" style="padding-bottom: 1em; color: #333333; font-size: 14px; line-height: 1.3"> @markup.DynamicInvoke(this.ViewContext) </td> </tr> } 

which I call with razor markup, for example:

 @<text> We are writing to let you know that @ViewBag.HostName has canceled @ViewBag.TripName and we've removed the trip from your My Trips page. <br /> <br /> To plan a new trip, go back to Travefy <br /> </text> 

However, I do not know the syntax to get the ViewContext page, because although I saw this.ViewContext in the example, this does not exist in the helper. Any ideas where I can access it?

+4
source share
1 answer

You need to pass the ViewContext object to your helper method as a parameter.

0
source

Source: https://habr.com/ru/post/1482473/


All Articles