I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with "return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle 7 18714
Try to add "return" to tell the button to depend on the return value of the
script that is being called.
instead of: OnClientClick="myButtonClick();"
use this: OnClientClick="return myButtonClick();"
Cheers!
"Ea******@HighFlyingBirds.com" wrote:
I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with "return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
View html source for the rendered page. What is there for myButton?
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Ea******@HighFlyingBirds.com"
<Ea************************@discussions.microsoft. comwrote in message
news:38**********************************@microsof t.com...
>I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with "return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
What?
"Eliyahu Goldin" wrote:
View html source for the rendered page. What is there for myButton?
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Ea******@HighFlyingBirds.com"
<Ea************************@discussions.microsoft. comwrote in message
news:38**********************************@microsof t.com...
I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with "return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
When viewing the page in the browser, rightclick the browser window and
choose "View Source" (that is in IE, other browsers may have different name
for the same function). You will see the html for the page you are viewing.
Then find in the html a control with id containing "myButton". You will see
what html code asp.net produced for the button. It may help you in
understanding the problem.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Jon Gonzales" <jo********************@me.comwrote in message
news:89**********************************@microsof t.com...
What?
"Eliyahu Goldin" wrote:
>View html source for the rendered page. What is there for myButton?
-- Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Ea******@HighFlyingBirds.com" <Ea************************@discussions.microsoft .comwrote in message news:38**********************************@microso ft.com...
>I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with
"return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
Definitely not, it doesn't make sense viewing the rendered script for the
button, just to the return thing, it will definitely fix the problem.
Correct me if I'm wrong.
Cheers!
"Eliyahu Goldin" wrote:
When viewing the page in the browser, rightclick the browser window and
choose "View Source" (that is in IE, other browsers may have different name
for the same function). You will see the html for the page you are viewing.
Then find in the html a control with id containing "myButton". You will see
what html code asp.net produced for the button. It may help you in
understanding the problem.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Jon Gonzales" <jo********************@me.comwrote in message
news:89**********************************@microsof t.com...
What?
"Eliyahu Goldin" wrote:
View html source for the rendered page. What is there for myButton?
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Ea******@HighFlyingBirds.com"
<Ea************************@discussions.microsoft. comwrote in message
news:38**********************************@microsof t.com...
I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with
"return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
You are right, adding "return..." is necessary. But I am referring to the
OP's statement:
... The client-side handlers end with
"return
false;" but they are never called.
If the event handler indeed is never called, viewing html will help.
--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Jon Gonzales" <jo********************@me.comwrote in message
news:33**********************************@microsof t.com...
Definitely not, it doesn't make sense viewing the rendered script for the
button, just to the return thing, it will definitely fix the problem.
Correct me if I'm wrong.
Cheers!
"Eliyahu Goldin" wrote:
>When viewing the page in the browser, rightclick the browser window and choose "View Source" (that is in IE, other browsers may have different name for the same function). You will see the html for the page you are viewing. Then find in the html a control with id containing "myButton". You will see what html code asp.net produced for the button. It may help you in understanding the problem.
-- Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Jon Gonzales" <jo********************@me.comwrote in message news:89**********************************@microso ft.com...
What?
"Eliyahu Goldin" wrote:
View html source for the rendered page. What is there for myButton?
-- Eliyahu Goldin, Software Developer Microsoft MVP [ASP.NET] http://msmvps.com/blogs/egoldin http://usableasp.net
"Ea******@HighFlyingBirds.com" <Ea************************@discussions.microsoft .comwrote in message news:38**********************************@microso ft.com... I am having trouble getting client-side events to fire on ImageButtons.
Instead I am seeing postbacks. The client-side handlers end with
"return
false;" but they are never called.
<asp:ImageButton id="myButton" runat="server"
OnClientClick="myButtonClick();" src=... ></asp:ImageButton>
In the javascript:
function myButtonClick()
{
alert("myButton clicked");
return false;
}
What can the problem be?
Thank you!
Eagle
I'm having the exact same issue as OP's. I have a master page with an
"authentication" control at the top that contains a username and
password text inputs. There is a "login" ImageButton. The login image
button has postback event (click event) and OnClientClick function
call that simply "return false;". If I make
OnClientClick="alert('hello'); return false;", it does what I expect.
However, if I do OnClientClick="return myFunction();" where
myFunction() { return false; }, I get a postback. I'm curious if the
original post developer is also using master pages.
-ak This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tee |
last post by:
Hi,
I have a server control Table with each row will contain a dynamic created
ImageButton.
And I have a private sub with the proper delegate of an ImageButton click
which handle nothing....
|
by: DalePres |
last post by:
Does anyone know if there is a known bug or workaround, or other solution to
this problem?
I have a page with several imagebutton server controls and needed to
handle the PreRender event in C#....
|
by: Darren Clark |
last post by:
I have an image button on a page
<asp:ImageButton Runat=server ID="btSimpleSearch" onMouseOut="this.src = 'images/button_search_n.gif'"
onMouseOver="this.src = 'images/button_search_r.gif'"...
|
by: ruca |
last post by:
Hi gurus,
I have a imagebutton in my WebForm, and I want that when I click (mouse
down) on her the imagebutton change image and when I "unclick" (mouse up)
change to the original image.
Basically...
|
by: sck10 |
last post by:
Hello,
When a person subits my web page, I do a simple check (validation) and if
there are any errors, I create a variable (strValidateText) and set that
value to a label on the form. What I...
|
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...
|
by: Lagwagon |
last post by:
I have an Image Button inside of a Datagrid and its not firing the
datagrid.itemcommand event when it is clicked. Does anyone have a link to a
tutorial or a solution for this problem?
For my...
|
by: Tom Edelbrok |
last post by:
I'm using VS 2005 to develop an intranet asp.net web application and I get a
weird situation. If I start out with any ASPX page that contains an
ImageButton control followed by a TextBox control,...
|
by: TimmyTurner |
last post by:
Hi all
I'm working on a ASP.NET, C# project on Visual Studio 2005, using a MSDB in _vista_.
My problem is that the events for the buttons are not firing.
I've searched the web and the solution...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
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...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
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...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |