I don't want to postback

  • Thread starter Thread starter Jaime
  • Start date Start date
J

Jaime

Hi all,

I'm not sure if this is the correct forum, but here goes.

Is there a way to not post back after a button (actually imagebutton) is
clicked?

I have something like:
<asp:ImageButton ID="something" ImageUrl="pic.gfx" Runat="Server"
OnClick="ViewDetails('"+id+"')" />

now, this works fine for opening a new window to display the details of the
selected record, but it also causes a postback on the page and I really
don't need it since nothing has changed on the parent page...

Any help?

thanks
 
Jaime,

The problem arises due to the fact that you are using a imagebutton. I think
for your requirement you should be using a hyperlink (can take imageurl).

set the NavigateUrl to "#"
and add an attribute from code behind using

lnkOpener.Attributes.Add("onclick", "ViewDetails('"+id+"')");

this should prevent the postback and still execute ViewDetails which i
presume calls appropriate aspx page with correct id.

HTH

Regards,

Hermit Dave
http://hdave.blogspot.com
 
Why don't you just use an Image control instead of an ImageButton control?
 
Thanks for the tip. That worked great. Now I have a different question, is
there a way to keep track of the "parent" or "caller" page so when I'm done
updating data in the detail view I can PostBack on the parent page and get
the updated data?

Thanks
Jaime
 
you can use
window.opener.document.location.reload();
or
window.opener.document.location.href = 'abc.aspx';

can be used to either reload opener or redirect opener to another page

HTH

Regards,

Hermit Dave
http://hdave.blogspot.com
 
Back
Top