Bootstrap nav-tab event run on server side c #

5

I'm using the following code to use tabs in my Asp.Net application, is there any way to add an event so that when I change tab I run some server-side event equal to the TabContainer event of ajaxcontroltoolkit? ( link )

I'm not using TabContainer because I can not apply Bootstrap to it.

I found the code below but it does on the client side.

link

$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
  var target = $(e.target).attr("href") // activated tab
  alert(target);
});

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><scriptsrc="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>

<ul id="myTab" class="nav nav-tabs">
  <li class="active"><a href="#home" data-toggle="tab">Home</a></li>
  <li class=""><a href="#profile" data-toggle="tab">Profile</a></li>
</ul>
<div id="myTabContent" class="tab-content">
  <div class="tab-pane fade active in" id="home">
    home tab!
  </div>
  <div class="tab-pane fade" id="profile">
    profile tab!
  </div>
</div>
    
asked by anonymous 22.03.2016 / 21:09

1 answer

1

Instead of using normal link you can use asp.net LinkButton and get the click event on the server side:

<ul id="myTab" class="nav nav-tabs">
<li class="active"><asp:LinkButton data-toggle="tab" OnClick="Method_Click">Home</a></li>
<li class=""><asp:LinkButton data-toggle="tab" OnClick="Method_Click"></li>
</ul>
<div id="myTabContent" class="tab-content">
 <div class="tab-pane fade active in" id="home">
     home tab!
  </div>
   <div class="tab-pane fade" id="profile">
    profile tab!
  </div>
</div>
    
24.03.2016 / 18:11