":" is not valid at the start of a code block. Only identifiers, keywords, comments, "(" and "{" are valid.

alattin (16999) 10 yıl önce sordu

CsHtml dosyası içerisinde, HTML kodlar arasında 

@if( i > 4)
{
    <div class="row">
}

gibi Razor ve HTML kodları karışık bir ifadem var ve bu ifadenin olduğu yerde 

Server Error in '/' Application.

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: ":" is not valid at the start of a code block.  Only identifiers, keywords, comments, "(" and "{" are valid.

şeklinde hata alıyorum. Sebebi ne olabilir?

Toplam 1 cevap


alattin (16999) 10 yıl önce cevapladı

Razor ifadelerin içerisinde Html etikerleri kullanırken hatadan kaöınmak için  @: kullanılmalıdır

@if(i > 4)
{
    @:<div class="row">

}

veya <text> etiketi de kullanılabilir

@if(i > 4)
{
    <text>uzmanim.net</text>
}