Imports System.Linq.Expressions Imports System.Web.Mvc Imports System.Web.Routing Imports System.Runtime.CompilerServices Imports System.Text Public Class SpanFor Public Shared Function SpanFor(Of TModel, TProperty)(helper As HtmlHelper(Of TModel), expression As Expression(Of Func(Of TModel, TProperty)), Optional htmlAttributes As Object = Nothing) As MvcHtmlString Dim valueGetter = expression.Compile() Dim value = valueGetter(helper.ViewData.Model) Dim span As TagBuilder("span") span.MergeAttributes(New RouteValueDictionary(htmlAttributes)) If value IsNot Nothing Then span.SetInnerText(value.ToString()) End If Return MvcHtmlString.Create(span.ToString()) End Function End Class
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)