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

  • SEARCH
  • Home
  • 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 6223757
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:32:40+00:00 2026-05-24T08:32:40+00:00

I am trying to load a partial view which has a tabstrip. I am

  • 0

I am trying to load a partial view which has a tabstrip. I am making a jQuery ajax call to the controller which returns a partial view which contains the tab strip. I believe all the Telerik JS is being loaded properly.

Here are pieces of the partial view:

        <% Html.Telerik().TabStrip()
        .Name("TabStrip")
        .Items(tabstrip =>
        {
            foreach (FooType foo in Model.Section) {
                tabstrip.Add()
                    .Text(foo.Name.ToString())
                    .Content(() =>
                    {%>
                        <div><%= foo.bar.ToString() %></div>
                    <%});
            }
        })
        .SelectedIndex(0)
        .Render();
         %>

The problem is that has the same content no matter what. Its always the last item from Model.Section. The tab text is is outputted correctly though.

I’ve tried replacing the foo.bar.ToString with a counter that get incremented at each iteration, but the tabs end up all having the same value, the last counter value.

What am I missing?

  • 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-05-24T08:32:41+00:00Added an answer on May 24, 2026 at 8:32 am

    This is a well known problem caused by the lambda capturing the foo variable by reference not by value. When the tabs are rendered the last value of foo will be used. Check this blog post for a more detailed explanation.

    The solution is to use a local variable inside the loop:

    foreach (FooType foo in Model.Section) {
          var bar = foo.bar.ToString();
          tabstrip.Add()
                  .Text(foo.Name.ToString())
                  .Content(() => /* use the local variable in the lambda */
                   {%>
                       <div><%= bar %></div>
                   <%});
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to load fragments of XHTML markup using jQuery's $.fn.load function, but it
I am trying to load a dynamic library using dlopen function. This library contains
What I'm trying to do is pass parameters to a user control view which
I'm trying to use jQuery to load a PartialView. It does this fine at
I am using Loading a partial view in jquery.dialog as a reference in order
I am using Ruby on Rails and am trying to load a page which
I'm trying to make a partial view that acts as the following: When user
I am loading a partial view into a main view using ajax but struggling
I am trying to load Linq on my .Net 3.5 enabled web server by
I'm trying to load a page that is basically an edit form inside a

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.