In a View, I have a Razor code like
@Code
Dim x As String = "MyTest"
End Code
However, how can I share that code with other Views without copy/paste it in all the Views?
In a View, I have a Razor code like
@Code
Dim x As String = "MyTest"
End Code
However, how can I share that code with other Views without copy/paste it in all the Views?
You can create a partial view, and then use the following code to render the partial view on your other pages:
@Html.RenderPartial("Path to partial view")
You can also pass a model to a strongly-typed partial view by including a second parameter:
@Html.RenderPartial("Path to partial view", myModel)