Control of type 'ImageButton' must be placed inside a form tag with runat=server. I thought MVC didn't use this?
I thought one of the benefits of using ASP.Net MVC2 was the cleaner and more logical markup you could make for a webpage.
I'm creating the design of my master page and when I try to run it I get this error:
Control 'ctl00_ImageButton1' of type 'ImageButton' must be placed 开发者_如何学编程inside a form tag with runat=server.
Here's the code:
<body>
<div id="headerarea">
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Content/logo.png" PostBackUrl="~/Views/Home/Index.aspx" />
<p><span class="salute"><strong>Hola.</strong></span> Inicie sesion para poder crear tus propios anuncios gratis! Eres nuevo? Empieza aqui.</p>
<div id="topmenu">
<img src="../../Content/categorybutton.png" alt="Nuestras categorias" />
<p>Buscar en</p>
</div>
</div>
</body>
What should I do to fix this error? Any tips?
ASP.Net MVC does not use any runat="server"
controls (except asp:ContentPlaceHodler
s for master pages).
You should use raw HTML instead:
<input type="image" src="<%=Url.Content("~/Content/logo.png")" />
Note that HTML <input>
tags must be inside a <form>
.
Also note that ~/Views/Home/Index.aspx
is not a valid path for the client.
You probably want a simple hyperlink instead:
<a href="/">
<img src=<%=Url.Content("~/Content/logo.png")" alt="Our Logo" />
</a>
精彩评论