Tuesday, August 31, 2010

ImageButton Without A SRC Value Causes GET Request!

Situation:

Click submit on a submit button.
Page posts back with IsPostBack == true.
Browser shows page render.

Problem:

Server (in debug mode) shows another request perform, this time a GET, so IsPostBack == false.

Evidence:

An ImageButton was on the page with no SRC attribute at all. This caused the browser (so far happening in (Windows...) Chrome, Firefox and (MAC...) Safari to resolve the URL of the image, for the image button, to be the same as the page the button is sitting on. The request for this then causes a standard GET request to the page and IsPostBack becomes false again.

Solution:

Remove the image button or give it a valid src attribute url.

Result:

Happy developer.

1 comment:

  1. Didn't know that! Thanks for the info :D

    David

    ReplyDelete