Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Controls > Stop Postback in image button

Reply
Thread Tools

Stop Postback in image button

 
 
nachoenjuto@gmail.com
Guest
Posts: n/a
 
      07-26-2006
Hi people

Does anyone know how whether there is any property, way or trick to
stop the postback of a image button??

I need the image button to change its behavour after the first click.
The image button expands an area that contains more information, The
first click would be a postback with a database query to get some extra
info and put it in expandable area.
The second click and consecutives would just collapse and expand this
expandable area

Does anyone know if this is posible with just jusing one image button??

Thank you!

 
Reply With Quote
 
 
 
 
Alessandro Zifiglio
Guest
Posts: n/a
 
      07-26-2006
hi, sure you can. Try the following code i used to make a simple example.

Regards,
Alessandro Zifiglio
http://www.AsyncUI.net

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void ImageButton1_Command(object sender, CommandEventArgs e)
{
/*do something here, it will fire only the first time the image
button is clicked.
the next time onwards, the following jscode will be injected
which cancels the submit and
instead makes it expand and collapse the the li node with id
'collapsible1'
*/
collapsible1.InnerText = "some stuff for the body, coming from your
database";
ImageButton1.Attributes.Add("onclick",
"document.getElementById('collapsible1').style.vis ibility =
((document.getElementById('collapsible1').style.vi sibility == 'visible') ?
'hidden' : 'visible'); return false");

}
</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<ul style="list-style-type:none">
<li>head <asp:ImageButton ID="ImageButton1" runat="server"
ImageUrl="~/url/to/your/image" OnCommand="ImageButton1_Command" /></li>
<li id="collapsible1" runat="server"
style="visibility:visible"></li>
</ul>

</div>
</form>
</body>
</html>
<> ha scritto nel messaggio
news: ups.com...
> Hi people
>
> Does anyone know how whether there is any property, way or trick to
> stop the postback of a image button??
>
> I need the image button to change its behavour after the first click.
> The image button expands an area that contains more information, The
> first click would be a postback with a database query to get some extra
> info and put it in expandable area.
> The second click and consecutives would just collapse and expand this
> expandable area
>
> Does anyone know if this is posible with just jusing one image button??
>
> Thank you!
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Stop postback/refresh using a button... Matthew Wells ASP .Net 3 09-16-2009 01:14 PM
stop button postback ajax in non-ie gerry ASP .Net 3 11-23-2007 02:53 AM
Inconsistent behavior of an asp.net button performing a postback when a button is clicked. Mossman ASP .Net 0 12-12-2005 02:55 AM
stop postback in postback events for server controls ?? Wael_Bakr ASP .Net Web Controls 0 11-30-2005 08:06 AM
HTML Reset Button Doesn't work after postback with Submit button Chris Lane ASP .Net 4 11-17-2003 11:52 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57