This is a migrated thread and some comments may be shown as answers.

[Solved] Rendering question

2 Answers 12 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Scott McClure
Top achievements
Rank 1
Scott McClure asked on 30 Nov 2010, 10:59 PM
Can someone explain to me why the following code gives me a tab strip with 3 different tabs ("A", "B", and "C"), but yet the content is all the same (in this case, "C")? I'm trying to dynamically set the content of the tabs on the server side but I'm not having any luck. Thanks!

<% Html.Telerik().TabStrip()
       .Name("TabStrip1")
       .Items(item =>
           {
               foreach (string str in new string[] {"A", "B", "C"})
               {
                   item.Add().Text(str)
                       .Content(() =>
                           {%>
                               <%= str %>
                           <%});
               }
           }
       ).Render();
   %>

2 Answers, 1 is accepted

Sort by
0
Atanas Korchev
Telerik team
answered on 01 Dec 2010, 08:08 AM
Hello Scott McClure,

 That's how lambda's work. They capture reference to the variable. When the lambda is later executed it uses the last value of that variable. You can check this blog post for additional reference.

Regards,
Atanas Korchev
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Scott McClure
Top achievements
Rank 1
answered on 01 Dec 2010, 06:00 PM
Got it. Thanks for your help.
Tags
TabStrip
Asked by
Scott McClure
Top achievements
Rank 1
Answers by
Atanas Korchev
Telerik team
Scott McClure
Top achievements
Rank 1
Share this question
or