2016-03-30 21 views
2

Temel olarak, bir ';' görüyorum hiçbir yerde görünmüyor. Nereden geldiği hakkında hiçbir fikrim yok ve bunun için belirgin bir kaynak yok.ASP.NET MVC4 HtmlHelper fazladan istenmeyen işaret çıktısı veriyor

Bu sınama sitesinde javascript veya css yok.

Benim Modeli: (Bu konularda değil o)

public class RegisterAccountViewModel 
    {   
     public long? Id { get; set; } 
     [Required] 
     public string FirstName { get; set; } 
     [Required] 
     public string LastName { get; set; } 
     [Required] 
     public string Email { get; set; } 
     [Required] 
     public string PhoneNumber { get; set; } 
     [Required] 
     public string AccountType { get; set; } 
     public string OrganizationName { get; set; } 
    } 

View (Test.cshtml):

@model RegisterAccountViewModel 
@{Layout = null;} 

<!DOCTYPE html> 

<html> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title>Test</title> 
</head> 
<body> 
<div> 
    <input type="text" placeholder="FirstName"/> 
    <br/> 
    @Html.TextBoxFor(m => m.LastName, new {placeholder = "Last Name" }); 
</div> 
</body> 
</html> 

Kontrolör

public class LoginController : Controller 
    { 
     [HttpGet] 
     public ActionResult Index() 
     { 
      return View(); 
     } 

     [HttpGet] 
     public ActionResult Test() 
     { 
      return View(); 
     } 

     [HttpPost] 
     [ValidateAntiForgeryToken] 
     public ActionResult Register(RegisterAccountViewModel model) 
     { 
      return null; 
     } 
    } 

image

neler verir?

Benim bölümümde herhangi bir sorun olmadığından emin olmak için, varsayılan şablonu kullanarak yeni bir mvc sitesi oluşturdum ve bir metin kutusu ekledim; Sonuç Soyadı TextBoxFor sonunda

enter image description here

cevap

4

Kaldır noktalı virgül ; aşağıdaki resimde görüldüğü gibi aynıdır.

@Html.TextBoxFor(m => m.LastName, new {placeholder = "Last Name" }); //<-- remove this semicolon 

NOT: - ustura olarak (MVC) Eğer @{} içindeki bazı C# kodu yazarken sözdizimi ; sadece gerekli olduğu, html yardımcı uzatma yöntemlerinin sonunda ; gerek yoktur.

+0

Lol :) şimdi im mahcup sana yardımcı olmaktan mutluluk :) – sergio

+0

istedi .. –

2

';' Sizce dip çizgiden:;)

@Html.TextBoxFor(m => m.LastName, new {placeholder = "Last Name" })