Making an image clickeable

garcon

Well-known member
Joined
Dec 13, 2004
Messages
47
Programming Experience
Beginner
Folks,

I have an image in the ".aspx" file that I want to make clickeable. That is, when a person clicks on it goes to the VB.NET file ".b.aspx"
Code in front file shown below:

HTML:
<input onmousedown="ValidateCurrencySelection()" id="imgSubmit" type="image" alt="Click here" src="images/EN.gif" border="0" name="imgSubmit">


Can anyone show me how to make this clickeable ie.e what do I need to put around the above to make it work and in the code-behind file please?

Thankx,
G.
 
Well you would use the <asp:ImageButton/>, why are you writing in straight code? Do you not have Visual studio?

TPM
 
Ah - well you see I saved some rendered source code from a page aand pasted it into Visual Studio - so I'm trying to reverse engineer it if you take my meaning...
 
Control 'imgSubmit' of type 'ImageButton' must be placed inside a form tag with runat

Now what I have is the following:

Front-end file:

HTML:
<asp:ImageButton id="imgSubmit"
runat="server" 
AlternateText="Click here to calculate the amount"
ImageAlign="left"
ImageUrl="images/EN.jpg"></asp:Imagebutton>

Code-behind file:

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


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.

Any ideas? I'm confused!
G
 
LOL I see. Just copying and pasting wouldn't work as the page has already been rendered. Adding <form> at the start of your code, and </form> at the end will fix that error.
 
Back
Top