简体   繁体   中英

Conversion from C# to VB with ASP.Net-mvc 4

I am trying to convert C# Razor Into VB Razor Have Trouble with the following

When I Change

(Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl }))
@Html.LabelFor(m => m.UserName)
@Html.LabelFor(m => m.RememberMe, new { @class = "checkbox" }) 

To

(Html.BeginForm(new With { .ReturnUrl = ViewBag.ReturnUrl }))
@Html.LabelFor(m => m.UserName)
@Html.LabelFor(m => m.RememberMe, new With { .class = "checkbox" })

I Get Error

"m not declare it may be inaccessible due to its protection level"

Also Kindly Explain This new C# Syntax

Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })

and its equivalent in VB

@Html.LabelFor(m => m.UserName)

should be

@Html.LabelFor(Function(m) m.UserName)

See: How to: Create a Lambda Expression (Visual Basic)


@Html.BeginForm(new { ReturnUrl = ViewBag.ReturnUrl })

respectively

@Html.BeginForm(new With { .ReturnUrl = ViewBag.ReturnUrl }

creates an anonymous type. See: Anonymous Types (Visual Basic)

Maybe this

@Html.BeginForm(New With { _
    Key .ReturnUrl = ViewBag.ReturnUrl _
})
@Html.LabelFor(Function(m) m.UserName)
@Html.LabelFor(Function(m) m.RememberMe, New With { _
    Key .[class] = "checkbox" _
})

If you refer to new { ReturnUrl = ViewBag.ReturnUrl } it's simply an anonyimous type.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM