?
Solved

imagebutton control causes page to postback - please help

Posted on 2006-04-27
5
Medium Priority
?
957 Views
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?

Sean


<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" />
0
Comment
Question by:bullrout
5 Comments
 
LVL 8

Expert Comment

by:Maher-Jendasi
ID: 16559512
Hi,

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
0
 
LVL 39

Assisted Solution

by:appari
appari earned 500 total points
ID: 16559588
add this in form load event

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

Assisted Solution

by:sachitjain
sachitjain earned 500 total points
ID: 16559622
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.

Regards
Sachit.
0
 
LVL 12

Accepted Solution

by:
bsdotnet earned 1000 total points
ID: 16559699
you can put "return false;" in input tag directly,

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

Author Comment

by:bullrout
ID: 16559821
Hi There,

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

Sean
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month14 days, 22 hours left to enroll

840 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