Load the RazorTemplate from Database

Aug 22, 2012 at 7:44 AM

hi scholars,

i have a query can anybody guide me properly. i have razortemplates stored in DB and i want to render the template from the code. as per the documentation i used the following way of approach

Note: My template language is Visual Basic so i used the configuration section to specify that.

 

and my code goes like this

Case1:

  Dim service = Razor.Services("myCustomTemplateService")
        Dim strTemplate As String = "Hi @Model.name!!"
        Dim obj As A1 = New A1() With { _
            .name = "maddy"
        }
        Response.Write(service.Parse(strTemplate, obj))
        'Output: Executing perfectly and showing the output as : Hi Maddy!!


Case2:
        Dim service1 = Razor.Services("myCustomTemplateService")
        Dim strTemplate4 As String = "<@Html.TextBoxFor()>"
        Dim result4 As String = service1.Parse(strTemplate4)
        Response.Write(result4)
        ' Showing Error: The 'ReferencedAssemblies' property cannot contain null or empty strings. Parameter(name) : options()

 

according to Case2 i want to render the plain TextBox but showing error like

The 'ReferencedAssemblies' property cannot contain null or empty strings. Parameter(name) : options()

 

Can anybody guide me the proper way to render the controls like Textbox, Dropdown,Checkbox and radiobuttons.