Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9241723
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:25:30+00:00 2026-06-18T08:25:30+00:00

I am using Bootstrap and have Tabs that are created dynamically. Although they are

  • 0

I am using Bootstrap and have Tabs that are created dynamically. Although they are dynamic, I will only create 3 Tabs. They are: Draft, Published and Archived. These are actually Enums.

When I click on a tab, I want to change a hidden field to the same value of the tab so that when Postback occurs, I wish to open the selected that was previously opened.

The tabs id is #i where i is the iterator within the for loop. So the Tabs will be: #0, #1 and #2.

Does anyone know how I can create one onclick event for all the tabs and make the hidden field’s value change to that of the Tabs id.

This is the the code:

<div class="tab-content">
    @for (int i = 0; i < Model.WorkflowStatuses.Count; i++)
    {
        <div class="tab-pane @(i == 0 ? "active" : string.Empty)" id="@i">

EDIT
This is what I have so far – The hidden field’s value isn’t changing however:

<script>
$('#listingTab a[data-toggle="tab"]').on('show', function (e) {
    $('#selectedTab').val($(e.target).prop('id'));
})

@Html.HiddenFor(m=>Model.SelectedTab)

@if (Model.AnyListings)
{
<ul class="nav nav-tabs" id="listingTab">
    @for (int i = 0; i < Model.WorkflowStatuses.Count; i++)

EDIT
I have added the letterl “t” but the hidden value still doesn’t change:

<script>
    $('#tab-content a[data-toggle="tab"]').on('show', function (e) {
        $('#SelectedTab').val($(e.target).prop('id'));
    })
</script>

@Html.HiddenFor(m=>Model.SelectedTab)

@if (Model.AnyListings)
{
    <ul class="nav nav-tabs" id="listingTab">
        @for (int i = 0; i < Model.WorkflowStatuses.Count; i++)
        {
            <li class="@(i == 0 ? "active" : string.Empty)"><a href="@string.Format("#t{0}", i)" data-toggle="tab">@Model.WorkflowStatuses[i].ToString()</a></li>
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T08:25:32+00:00Added an answer on June 18, 2026 at 8:25 am

    Try using the show event which fires whenever the active tab is changed:

    $('#yourTabControl a[data-toggle="tab"]').on('show', function (e) {
      $('#hiddenField').val($(e.target).prop('id'));
    })
    

    [EDIT]:

    After a chat we concluded the e.target is the link you clicked on, not the tab it activated. So to keep the code a bit easier I suggested to use a data-tabid attribute on the link:

    <li class="@(i == 0 ? "active" : string.Empty)">
      <a href="@string.Format("#t{0}", i)" data-toggle="tab" 
         data-tabid="@i">@Model.WorkflowStatuses[i].ToString()</a></li>
    

    And use that in the event handler:

    $('#yourTabControl a[data-toggle="tab"]').on('show', function (e) {
      $('#hiddenField').val($(e.target).data('tabid'));
    })
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using Toggable Tabs from Twitters Bootstrap The problem I have, Even you
I have an app that is using twitter-bootstrap and I am trying to implement
Here is my problem: The Problem I have created Tabs using jQuery which is
I have a site that is using bootstrap and ScrollSpy nav to scroll to
I'm using bootstrap (v2) and I see from http://twitter.github.com/bootstrap/components.html#dropdowns that you can have Split
I'm using Twitter bootstrap's tabs plugin and it requires the link that activates to
I am using twitter bootstrap and I have a form with link that should
So I'm using Twitter Bootstrap and I have a modal that slides down when
I am using bootstrap's grid, and I would like to have a div that
I have a page with tabs using twitter bootstrap and for tabs I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.