javascript - Animations/Transitions canceled by "onserverclick" -
first news:
sourcecode: http://jsfiddle.net/vwbn4/680/
i'm using normal html buttons in example instead of asp:buttons jsfiddle. have use asp elements read values in c# code behind.
as can see, got button changing it's color , size after click event. want have.
now bad news:
as can see, defined onserverclick="testfunc" button , got code behind:
protected void btnstatus_click(object sender, eventargs e) { //some functions getting parameters input, saving inputs anywhere, .... } and main problem:
after onserverclick event finished, whole website refreshed, animations/transitions canceled , button's css class reset.
im looking method, perform onserverclick background stuff without interfering client, clientside animations/transitions , other stuff.
thanks :)
one solution think use ajax update panel. using it's attribute updatemode="conditional" , triggers button (put outside update panel) in question can achieve animation along calling server side code , not have page refresh in process. below test code ran can check out solution.
html code
<html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> <style> .button { margin: 20px; font-family: inherit; border-style: solid; border-color: #bebebe; border-width: 2px; cursor: auto; font-family: arial; font-size: 17px; text-decoration: none; text-shadow: 0px 1px 0px #2f6627; text-align: center; padding: 15px 30px; height: inherit; width: 220px; display: inline-block; position: relative; background-color: #e9e9e9; color: #252525; border-radius: 0px; user-select: none; transition: 0.7s; } .active { background-color: #00b2e2; color: white; border-style: solid; border-color: #008fb6; border-width: 2px; transform: scale3d(1.1,1.1,1); } </style> </head> <body> <form id="form1" runat="server"> <asp:scriptmanager id="scriptmanager1" runat="server"></asp:scriptmanager> <div> <script> function toogleclass(ele, class1) { var classes = ele.classname; var regex = new regexp('\\b' + class1 + '\\b'); var hasone = classes.match(regex); if (hasone) { ele.classname = classes.replace(class1, ''); } else { ele.classname = classes + ' ' + class1; } } </script> <fieldset style="padding:100px;"> <legend>this update panel boundary</legend> <asp:updatepanel id="updatepanel1" runat="server" updatemode="conditional"> <contenttemplate> <label id="lbl1" runat="server">this default text</label> </contenttemplate> <triggers> <asp:asyncpostbacktrigger controlid="btnstatus" /> </triggers> </asp:updatepanel> </fieldset> <asp:button runat="server" type="button" id="btnstatus" class="button" onclientclick="javascript:toogleclass(this, 'active');" text="status" onclick="btnstatus_click"></asp:button> </div> </form> </body> </html> code-behind
protected void btnstatus_click(object sender, eventargs e) { lbl1.innertext = "this altered text after postback in update panel"; lbl1.style.add("background-color", "red"); } hope helps. happy coding.
Comments
Post a Comment