Reputation: 77
I am trying to make a project on ASP.NET using .aspx pages. The project also contains .cshtml files that support razor syntax unlike .aspx pages. Now, I am fairly new to web programming and not very familiar with what could be an alternative to using razor syntax in .cshtml or if it is possible to just use .cshtml views with ASP.NET, thus, completely avoiding .aspx pages.
For example how do I implement this code (that works in .cshtml)
@AntiForgery.GetHtml()
In .aspx page
Following are more code examples that I want to implement in .aspx but cannot:
<div class="form-group">
<label for="exampleInputEmail1" @if(!ModelState.IsValidField("email"))
{ <text> class="error-label" </text> }>
Email address
</label>
<input type="text" class="form-control" id="email" name="email"
value="@email" @Validation.For("email")/>
@Html.ValidationMessage("email")
</div>
Upvotes: 0
Views: 1238
Reputation: 49
It seems like your project is an ASP.NET MVC project with the mix between ASPX View Engine and Razor View Engine. Razor syntax and .cshtml are just parts of Razor View Engine whilst .aspx pages are of ASPX View Engine and both of them come from Web MVC framework. Of course, you could use .cshtml pages (Razor View) completely, it's just View Engine matter. But I'm not sure if you're familiar with MVC Pattern.
Upvotes: 1