c# - Stop page refresh after button click -


it not repeat post, have checked answers present on net , nothing working me i'm posting here.

please find code.

 <form runat="server">         <div class="card">             <ul class="nav nav-tabs main-menu" role="tablist">                 <li role="presentation" class="active"><a href="#enabled" class="element" style="font-size: 20px;" aria-controls="home" role="tab" data-toggle="tab">check box - enabled</a></li>                 <li role="presentation"><a href="#disabled" class="element" style="font-size: 20px;" aria-controls="profile" role="tab" data-toggle="tab">check box - disabled</a></li>             </ul>              <div class="tab-content">                 <div role="tabpanel" class="tab-pane active" id="enabled">                     <asp:checkboxlist runat="server" id="checkboxenabled" repeatdirection="horizontal">                         <asp:listitem text="selenium ide"></asp:listitem>                         <asp:listitem text="selenium rc"></asp:listitem>                     </asp:checkboxlist>                     <asp:button runat="server" text="submit" cssclass="btn btn-success elements-text" onclick="btnenabled_click" />                     <asp:label runat="server" id="lblenabled" cssclass="label success"></asp:label>                 </div>                 <div role="tabpanel" class="tab-pane" id="disabled">                     <asp:checkboxlist runat="server" id="checkboxdisbled" repeatdirection="horizontal" cellpadding="5" cellspacing="5" cssclass="element form-control">                         <asp:listitem text="selenium ide"></asp:listitem>                         <asp:listitem text="selenium rc" enabled="false"></asp:listitem>                         <asp:listitem text="selenium webdriver"></asp:listitem>                         <asp:listitem text="selenium grid" enabled="false"></asp:listitem>                     </asp:checkboxlist>                     <asp:button runat="server" id="btndisabled" text="submit" cssclass="element btn btn-success" onclick="btndisabled_click" />                     <asp:label runat="server" id="lbldisabled" cssclass="label success"></asp:label>                 </div>             </div>         </div>     </form> 

i'm having 2 tabs in page, when i'm on second tab, select 1 checkbox , click on button #btndisabled page gets postback , navigates first tab. want stop.

i have tried, 1. autopostback = false 2. onclick = "return false;" not able solve issues.

any appreciated. :)

you can save index of active panel in hidden control , use after post back.

<input type="hidden" runat="server" id="tabindex" value="0" /> 

i not know how switch between tabs, on each tab change must save it's index in hidden field(by javascript). example if select second tab, value of hidden field must change 1.

finally add script after of tabs.

var tabindex = $('#tabindex').val(); $('.tab-pane').removeclass('active'); $('.tab-pane').eq(tabindex).addclass('active'); 

Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -