473,326 Members | 2,128 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

HtmlInputImage and Postback event

In my Asp.net application, I have come across a situation where I cannot prevent a postback using the HtmlInputImage control. If I use the HtmlInputButton, the post back is not automatic, however with the HtmlInputImage, it appears to be.

Add this to your aspx test app and set a breakpoint in your Page_Load.
<input type="button" id="TheButton" value="GO"/>
<input type="image" id="TheImage"/>

When you click on the "TheButton" - no postback occurs. When you click on "TheImage" - a postback occurs. Can someone help me stop the postback for the HtmlInputImage?

Thanks,

Alex
Nov 18 '05 #1
2 2628
Hi Alex

U r right the image click is posting the page to the server. It seems some browser setting is causing the page to post on image click.

I did a workaround by putting onclick="return false;" in the input image control and it no longer submits the page to the server.

<input type="image" id="TheImage" onclick="return false;" />

HTH

"Alex" <al**@nospam.net> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
In my Asp.net application, I have come across a situation where I cannot prevent a postback using the HtmlInputImage control. If I use the HtmlInputButton, the post back is not automatic, however with the HtmlInputImage, it appears to be.

Add this to your aspx test app and set a breakpoint in your Page_Load.
<input type="button" id="TheButton" value="GO"/>
<input type="image" id="TheImage"/>

When you click on the "TheButton" - no postback occurs. When you click on "TheImage" - a postback occurs. Can someone help me stop the postback for the HtmlInputImage?

Thanks,

Alex
Nov 18 '05 #2
Thanks for the help. Adding return false; to my onclick even solved this issue.

--
Alex
"Vaibhav" <co************@yahoo.com> wrote in message news:OA**************@TK2MSFTNGP14.phx.gbl...
Hi Alex

U r right the image click is posting the page to the server. It seems some browser setting is causing the page to post on image click.

I did a workaround by putting onclick="return false;" in the input image control and it no longer submits the page to the server.

<input type="image" id="TheImage" onclick="return false;" />

HTH

"Alex" <al**@nospam.net> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
In my Asp.net application, I have come across a situation where I cannot prevent a postback using the HtmlInputImage control. If I use the HtmlInputButton, the post back is not automatic, however with the HtmlInputImage, it appears to be.

Add this to your aspx test app and set a breakpoint in your Page_Load.
<input type="button" id="TheButton" value="GO"/>
<input type="image" id="TheImage"/>

When you click on the "TheButton" - no postback occurs. When you click on "TheImage" - a postback occurs. Can someone help me stop the postback for the HtmlInputImage?

Thanks,

Alex
Nov 18 '05 #3

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

Similar topics

2
by: CodeRazor | last post by:
I am building my html page in .net. After i click a button, i want an outline/border to appear around my button. I have found the HtmlInputImage.Border property and although it prints out...
5
by: JP | last post by:
ow do I get a HtmlInputImage to raise the ServerClick event I have two inputs one is a submit button the other is a image. The submit button works the input image does not. Does anyone know why...
5
by: Matthew Louden | last post by:
I created simple ASP.NET web application to test how AutoPostBack property in a web control works. I set AutoPostBack property to be true of a web control. When I run the application, here's the...
1
by: Earl Teigrob | last post by:
I did a ton of searching to try and find a simple solution to this issue and finally wrote my own, which I am sharing with everyone. In my searching, I did find a very complete and robust solution at...
2
by: RAJ | last post by:
In our multi-tier application, we have several ASP.NET user controls which will update the same data source provided by middle tier logic. In this particular scenario we have one user control...
11
by: CW | last post by:
I have message entry screen that's causing me a bit of an issue. At the moment, there are 2 buttons, one is used to send message to another user (btnSend) and another is used to send messages to...
8
by: walesboy | last post by:
greetings - I have a btnSubmit button with a Handles btnSubmit.click which works great if all the user does is click that button. But, if the user ALSO changes a text box on the page (which...
6
by: schleichv | last post by:
Hello, I am attempting to get the ServerClick event to fire on a dynamically generated HtmlInputImage and having no luck at all. I've looked over many items on the forums but none seem to cover...
2
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.