Archive for June, 2014

asp.net mvc – mixing razor code with css

June 26, 2014

1) vb syntax
2) purpose: hide/show a div from razor (I realize it’s possible to do this easily in jquery)

the page/view:
Html.BeginForm(“results”, “Results” )

@

Html.EndForm()

the css:
.dvPaging {
@Model.NotPaged()
vertical-align:text-top;
width:50%;
height: 20px;
}

the razor code:
I think it’s best to do what we need in a function.
I put presentation layer code in my view model

‘ purpose – called by the css to show or hide the paging section based on whether there are more than
‘ one page or not
Public Function NotPaged() As String
Dim sRet As String = “”
If (Not isPagination) Then sRet = “display:none; height:0px;”
Return sRet
End Function