Go Back  Xtreme Visual Basic Talk > Other Languages > Web Programming > Control 'imgSubmit' of type 'ImageButton' must be placed inside a form tag with runat

Thread Tools Display Modes
Old 12-16-2004, 05:03 AM
garcon garcon is offline
Join Date: Dec 2004
Posts: 38
Default Control 'imgSubmit' of type 'ImageButton' must be placed inside a form tag with runat

I'm getting a strange error message when I attempt to run this code. It compiles fine. I'm trying to create na imagebutton - a clickeable image. Can you help me please?

HTML Code:

HTML Code:
<asp:ImageButton id="imgSubmit"
AlternateText="Click here to calculate the amount"
Code-behind file:

Sub imgSubmit_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
Response.Write("click detected")
End Sub

But I'm getting the following error message:

Control 'imgSubmit' of type 'ImageButton' 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 'imgSubmit' of type 'ImageButton' must be placed inside a form tag with runat=server.

It is in a form tag as follows:

<form id="DccResult" name="DccResult" action="DccSelection.aspx?BaseCurrency=EUR&amp;Culture=EN&amp;BaseAmount=166.56"
Any ideas? I'm confused! Please help!
Reply With Quote
Old 12-16-2004, 06:40 AM
Minaki Minaki is offline
Join Date: Dec 2004
Location: Guildford, UK
Posts: 3

Web controls need to be placed in a server form to work. A server form is a form that has an attribute called runat which is set to the value "server" like this:

<form runat="server">

As you are using a standard form, not a web form, you can't use web controls. Either make a page with a server form, or don't use the web control for an image button - use <input type="image"...> instead.
Reply With Quote

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump


Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..