2013-05-07 24 views
8

Bu sözdiziminin neden "Hata bildirme hatası nedeniyle girilemedi." Ve "@html (" ifadesini " hatası.Razor VB.net MVC'de kullanılması beklendiği gibi çalışmaz

Bu blok şikayet hata

@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post)) 
     Enter User id :- @Html.TextBox("UserId",Model) -- This line must write in this way @Html("Enter User id :-") 
     <input type="submit" value="Submit data" /> --This line complain ">" expected" 
    End Using 

bu şekilde kodunu yeniden Eğer gitmiş ama çıkış ekran "System.Web.MVC.Html"

aşağıdaki resim gibi başında şikayet
 @Html.BeginForm("GetUser", "UserProfile", FormMethod.Post) 
     Enter User id :- @Html.TextBox("UserId",Model) 

    <input type="submit" value="Submit data" /> 

enter image description here

hi nemesv Kullanım @<Text>
, bu şikayet ise - "Kullanma End ile bitmelidir kullanma"> enter image description here

+0

Sen yakın unuttum ' @' Ben benim örnekte bakın: ' @' sonundaki kapanış '' not çizgi. – nemesv

+0

Oppps! MVC'de çok yeni. her şey bana yeni geliyor, teşekkürler! – tsohtan

+0

olası bir kopyası niçin [Bir Html.BeginForm'un @Using içinde normal biçimlenmesi neden bir @ 'ye ihtiyaç duyar?] (Http://stackoverflow.com/questions/10225394/why-does-normal-markup-inside-an-using-html- beginform-need-an) – KyleMit

cevap

8

Bir Using bloğunun içinde olduğunuz zaman Razor içinde "kod modunda" olan . Bu nedenle, "metin moduna" ve çıkış html'ye geri dönmek için (tek satırlı deyimler için) veya @<text> .. </text> (çok satırlı deyimler için) kullanmanız gerekir. @: kullanılarak ile

:

@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post)) 
     @<text>Enter User id :-</text> @Html.TextBox("UserId",Model) 
     @<text><input type="submit" value="Submit data" /></text> 
End Using 

ayrıca bilgi için Combining text, markup, and code in code blocks bölümüne bakın:
@Using (Html.BeginForm("GetUser", "UserProfile", FormMethod.Post)) 
     @:Enter User id :- @Html.TextBox("UserId",Model) 
     @:<input type="submit" value="Submit data" /> 
End Using 

veya @<text> kullanılarak

.

+0

'@' '''ün önünde bir VB şey var mı? Bunun gerekli olmadığını biliyorum C# – mattytommo

+1

@mattytommo evet @ 'sadece C# içinde sadece bir şey var sadece ' – nemesv

+0

ihtiyacım var bu hatayı alıyorum: '>' tarayıcıda çalıştırıldığında bekleniyor. bu satırda @: ama tasarım zamanında ve ayrıca @ benim için çalışmıyor. Ben vs 2012. kullanıyorum. Net 4.5 – tsohtan

İlgili konular