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


Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2004, 05:03 AM
garcon garcon is offline
Freshman
 
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"
runat="server" 
AlternateText="Click here to calculate the amount"
ImageAlign="left"
ImageUrl="images/EN.jpg"></asp:Imagebutton>
Code-behind file:

Code:
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:

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

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">
</form>

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
Reply


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

Advertisement:





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.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
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..
subscribe
 
 
-->