HtmlInputImage and Postback event

A

Alex

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
 
V

Vaibhav

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

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
 
A

Alex

Thanks for the help. Adding return false; to my onclick even solved this issue.

--
Alex
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

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top