VB.NET 2015中的Tagbuilder [英] Tagbuilder in VB.NET 2015

查看:100
本文介绍了VB.NET 2015中的Tagbuilder的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好......

请帮帮我。

i使用vb.net 2015.我想做customerhelper,我尝试使用tagbuilder,但我可以'找到了tagbuilder。



i不知道为什么......请帮帮我。



< b>我尝试了什么:



hi guys...
please help me.
i use vb.net 2015. and i want to make customehelper and i try use tagbuilder, but i can't found the tagbuilder.

i don't know why... please help me.

What I have tried:

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

推荐答案

你需要一些东西:

1)你必须使用.NET Framework 4.x.



2)添加对System.Web.WebPages.dll的引用。如果您已经在MVC项目中,这应该已经存在。



3)将Imports System.Web.Mvc添加到您尝试使用的文件的顶部如你所见,上课。
You need a few things:
1) You have to be using .NET Framework 4.x.

2) Add a reference to System.Web.WebPages.dll. If your already in a MVC project, this should already exist.

3) Add Imports System.Web.Mvc to the top of the file you are trying to use the class in, as you already are.


这篇关于VB.NET 2015中的Tagbuilder的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆