0
我想在Visual Basic中學習ASP.NET MVC 4,因爲我們在VB WebForms項目中有一個MVC部分。但是所有在線教程都是用C#編寫的。將C#代碼轉換爲VB實際上是測試我對VB的知識(我在C#中的技能是基本的)。我終於停留在這行代碼在C#:如何在Visual Basic中使用[Bind(Exclude =「fieldName」)?
public ActionResult Create([Bind(Exclude="CurrentPrice")] Models.Auction.auction)
我無法弄清楚如何在[綁定]註釋添加到同一線路在Visual Basic中:
Function Create(ByVal auction As MvcAuction.Auction) As ActionResult
我已經試過:
<Bind(Exclude="CurrentPrice")> _
Function Create(ByVal auction as MvcAuction.Auction) As ActionResult
產生這樣的錯誤:屬性「BindAttribute」不能被應用到「創建」,因爲屬性不是在此聲明類型有效。
我也試過這樣:
Function Create(ByVal <Bind(Exclude = "CurrentPrice")> auction As MvcAuction.Auction) As ActionResult
這
Function Create(ByVal auction As <Bind(Exclude = "CurrentPrice")> MvcAuction.Auction) As ActionResult
在這兩種情況下,我得到一個 '預期標識符' 錯誤。
有誰知道正確的VB語法?
更一般地說,我一直無法在MVC中找到任何關於VB語法的MSDN文檔。有誰知道在哪裏可以找到使用VB與MVC良好的文檔?
你可以試試:Function Function Create( test_auction As Models.Auction)As ActionResult' –
Hackerman
工作的代碼是:函數Create( ByVal test_auction As MvcAuction .Auction)作爲ActionResult。謝謝。你有沒有找到任何好的MVC VB文檔? –
足夠接近:) – Hackerman