imagebutton control causes page to postback - please help

Posted on 2006-04-27
Last Modified: 2012-06-22
Hi There,

I have some image controls on a page and when I click them it causes the page to postback, thus i'm having to re-bind the data and re-load the page everytime this is done. Could someone tell me how I can use the buttons without causing the page to postback? Can I disable it or something to that effect?


<input type="image" name="imgtrailer1" id="imgtrailer1" class="imagetrailer" onclick="javascript:openWindow('viewtrailer.aspx?id=1','trailer',350,230)" src="img/trailer1.jpg" alt="" border="0" />
Question by:bullrout
    LVL 8

    Expert Comment


    In ASP.NET the AutoPostBack property can control if automatic post back is performed whenever you *change* anything on the control and lost focus, however because the ImageButton control you actually do not change anything, it does not have such property, therefore you can not disable the postback of ImageButton.

    My rrecommendation is to use an ordinary HTML control instead, for example, the Image control
    LVL 39

    Assisted Solution

    add this in form load event

    ImageButton1.Attributes.Add("onclick", "return false;")
    LVL 12

    Assisted Solution

    You could create a JS function like

    function windowOpen(url, title, x, y)
          openWindow(url, title, x, y);
          return false;

    and then in <image/> tag specify onclick="javascript:return windowOpen('viewtrailer.aspx?id=1','trailer',350,230);
    Return of false would prevent postback of ur page.

    LVL 12

    Accepted Solution

    you can put "return false;" in input tag directly,

    <input type="image" name="imgtrailer1" id="imgtrailer1" class="imagetrailer" onclick="'viewtrailer.aspx?id=1','trailer',350,230);return false;" src="img/trailer1.jpg" alt="" border="0" />
    LVL 5

    Author Comment

    Hi There,

    Thanks for replying so promptly ppl. I have used bsdotnet's answer.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on could not pull conte…
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    11 Experts available now in Live!

    Get 1:1 Help Now