Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net Web Controls (http://www.velocityreviews.com/forums/f63-asp-net-web-controls.html)
-   -   Stop Postback in image button (http://www.velocityreviews.com/forums/t778595-stop-postback-in-image-button.html)

nachoenjuto@gmail.com 07-26-2006 12:34 PM

Stop Postback in image button
 
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!


Alessandro Zifiglio 07-26-2006 04:09 PM

Re: Stop Postback in image button
 
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>
<nachoenjuto@gmail.com> ha scritto nel messaggio
news:1153917252.759049.54960@h48g2000cwc.googlegro 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!
>





All times are GMT. The time now is 09:16 PM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.