We have a default value for a textbox that is coming from a database and it is
@UserSession.NumberOfPeople
This is currently parsed by using
string value = Razor.Parse(Model.DefaultValue)
Which returns me the string value from that variable
However as Razor.Parse
is now obsolete, I was looking into an alternative way using Engine.Razor.Compile
but I can't seem to find an overload that isn't requiring a template
Is there a way of just parsing the the value as it is
string value = Razor.Parse("@UserSession.NumberOfPeople")
Or do I need to create some sort of template or install a nuget package for this?
You could use
RazorEngine
and simply use your string as the template:NOTE: For the
RunCompile
to accept astring
as a template you need to useRazorEngine.Templating
(@using RazorEngine.Templating
in your view).