ASP.NET MVC: Working with ASPX view engine w/o using helpers?

I hate those razor helpers. (LabelFor, TextboxFor...) they try to help me but they teach me nothing.

I want to try with ASPX engine. when I open it there is even toolbox on the left with all old good html commands. why can't i use it ?

how come that when i try to buil app intellisense say runat="server" is required when I know MVC doesn't need that ?

In brief how do I write HTML w/o using helpers ? Any constructive advice would be appreciated.


<%@ Page Language="VB" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>

<asp:Content ID="indexTitle" ContentPlaceHolderID="TitleContent" runat="server">Home Page</asp:Content>

<asp:Content ID="indexContent" ContentPlaceHolderID="MainContent" runat="server">
   <asp:ListBox runat="server">
        <asp:ListItem Text="text1" />
        <asp:ListItem Text="text2" />


`Server Error in '/' Application.
Control 'MainContent_ctl00' of type 'ListBox' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Web.HttpException: Control 'MainContent_ctl00' of type 'ListBox' must be placed inside a form tag with runat=server.

Source Error:

Line 22:                 <ul id="menu">
Line 23:                     <li><%: Html.ActionLink("Home", "Index", "Home")%></li>
Line 24:                     <li><%: Html.ActionLink("About", "About", "Home")%></li>
Line 25:                 </ul>
Line 26:             </div>`


You hate razor helpers, but you like to use predefined elements from the toolbox? Items in the toolbox are meant for webforms, but can be used for MVC as well. This is because MVC and webforms are still members of the family. However, I wouldn't really recommend to do that...

In brief how do I write HTML w/o using helpers ?

How do you write a simple text? Simply type the html tags as needed. You can use razor/aspx (doesn't really matter that much which one you choose) syntax to loop over your collections and construct the html based on your data. Nothing is forcing you to use razor helpers or webforms controls...

I think it may be the right time to learn a bit more about the technology you're using, because you seem to be confused about the really basic stuff here...

I hate those razor helpers. (LabelFor, TextboxFor...)

ASP.NET MVC is a very different pattern and concept than classic WebForms. If you don't like those new concepts this probably means that ASP.NET MVC is not for you. You could always go back to the classic WebForms development.

In brief how do I write HTML w/o using helpers ?

There's nothing in ASP.NET MVC that forces you to use helpers. You could perfectly fine write pure static HTML in your views:

<form action="/home/save" action="post">
    <label for="first_name">First name</label>
    <input type="text" name="first_name" id="first_name" />

    <label for="item">Select an item</label>
    <select id="item" name="item">
        <option value="1">item 1</option>
        <option value="2">item 2</option>
        <option value="3">item 3</option>

    <button type="sybmit">OK</button>

Obviously now you can forget about things like automatic data binding from the model, validation, routing, ...

As far as the problem you have with the ListBox inside a form with runat="server" is concerned, it seems that you have used some classic WebForms server side control in an ASP.NET MVC application which is not supported. Server side controls don't work in MVC because they depend on things like ViewState and require you to place them inside forms with runat="server", ... things that no longer exist in MVC.

So I would recommend you to go ahead and read some getting started tutorials about MVC here:

A ListBox is a .Net-ified SELECT element. In a razor template you can probably do something like:

<select id="list1">
  @for // some loop condition
    <option value="@Data.someValue">Text1</option>

... where @Data is bound to a model, and Text1 could also be similarly declared.

Need Your Help

if statement not working, outputs else statement instead

php wordpress if-statement

I'm trying to output the if statement, but instead the else statement shows. I have created a page using Wordpress and assigned this template to the page. I'm trying to show product image and conte...

Color in Console Application colors console-application

So I'm working on a console based application in visual basic and I ran into a problem. I am trying add color to the console but only to 1 word within the line. I know the Console.ForegroundColor =