|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Stop Postback in image buttonHi 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! 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.visibility = ((document.getElementById('collapsible1').style.visibility == '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> <nachoenj***@gmail.com> ha scritto nel messaggio Show quoteHide quote news:1153917252.759049.54960@h48g2000cwc.googlegroups.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! >
Stopping Attributes.Add from converting my JavaScript event code to HTML
ItemDataBound fires for header only ATTN MS: GridView improvements Require text entry - only if radio button checked GridViewRow FindControl failing GridView ScrollBar Page with User control loads twice. Expandable Section sumbit server form to another page Rename ID in Properties Window |
|||||||||||||||||||||||