473,472 Members | 2,208 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Clicking ImageButton Has No Effect

I'm trying to convert some old HTML pages to ASP.NET.

I'm experimenting with code that responds to a button click. But although
the mouse turns into a hand pointer when it is over the button, absolutely
nothing happens when I click it.

Does anyone know if this could have anything to do the fact that my button
is on a master page (along with the handler)? That shouldn't make any
difference should it?

My button looks like this:

<p>&nbsp;</p>
<asp:ImageButton runat="server" id="imgAddToCart"
ImageUrl="../images/addtocart.gif" OnClick="imgAddToCart_Click" />
<p>&nbsp;</p>

And at the top of the same master page, I have something like this:

<script runat="server">
protected void imgAddToCart_Click(object sender, ImageClickEventArgs e)
{
// Test code using HttpWebRequest here
}
</script>

Unfortunately, my project will not currently run in Visual Studio due to
some of the older constructs in the HTML code so I can't set breakpoints.
I'm just running it under Expression Web. But shouldn't the page refresh
after the postback or something? I get nothing.

Any tips appreciated.

Jonathan

Oct 5 '07 #1
1 1631
On Oct 5, 2:13 pm, "Jonathan Wood" <jw...@softcircuits.comwrote:
I'm trying to convert some old HTML pages to ASP.NET.

I'm experimenting with code that responds to a button click. But although
the mouse turns into a hand pointer when it is over the button, absolutely
nothing happens when I click it.

Does anyone know if this could have anything to do the fact that my button
is on a master page (along with the handler)? That shouldn't make any
difference should it?

My button looks like this:

<p>&nbsp;</p>
<asp:ImageButton runat="server" id="imgAddToCart"
ImageUrl="../images/addtocart.gif" OnClick="imgAddToCart_Click" />
<p>&nbsp;</p>

And at the top of the same master page, I have something like this:

<script runat="server">
protected void imgAddToCart_Click(object sender, ImageClickEventArgs e)
{
// Test code using HttpWebRequest here
}
</script>

Unfortunately, my project will not currently run in Visual Studio due to
some of the older constructs in the HTML code so I can't set breakpoints.
I'm just running it under Expression Web. But shouldn't the page refresh
after the postback or something? I get nothing.

Any tips appreciated.

Jonathan
At first glance, it looks like your imgAddToCart_Click method is not
bound to the click event of the button. In VB.net, you would declare
the method:

protected sub imgAddToCart_Click(object sender, ImageClickEventArgs e)
handles imgAddToCart.Click

Notice the _handles imgAddToCart.Click_ after the method declaration.

I use the OnClick HTML attribute when I want the button to call some
client-side Javascript before firing the server-side Click event.

HTH,

-A

Oct 6 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Gaëtan | last post by:
I want to post my form by clicking on a RadioButton but not on clicking on an ImageButton. How to do to execute only the click procedure of the ImageButton and not the postback of my page. Because...
1
by: Sue | last post by:
For performance purposes, I am using client-side scripts to show-hide (via css display: hide, display: block) several rows of a table depending on which imagebutton is clicked. Because of workplace...
2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
3
by: tshad | last post by:
I was trying to change my asp:button to asp:ImageButton, but got a message saying that ImageButton does not have an onClick function. How do I get the ImageButton call a function? Thanks, ...
2
by: CJ Oakwood | last post by:
Morning - I am hoping somebody from this group can help me out here... I have been trying to add an array of ImageButtons to my WebForm however I keep getting an exception that I can't seem to...
1
by: Nathan Sokalski | last post by:
I want to create a pushbutton-like control on my webform that has an image on it. I used to think that this is what the ImageButton control was, but it seems to me that the ImageButton is nothing...
2
by: Bendik Engebretsen | last post by:
I'm an ASP newbie and have just started experimenting with ASP.NET 2.0 using the VS.NET 2005 Beta. As a starting point I have used the 'Personal WEB site' starter kit. I am now trying to figure...
3
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.