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

Last Tab Content repeated in all tabs - ASP.NET MVC using Razor engine (CSHTML)

0 Answers 57 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Prabhat
Top achievements
Rank 1
Prabhat asked on 03 Aug 2012, 02:25 AM
Hi
Using the TabStrip UI element in our ASP.NET MVC 3 application using the Razor engine and binding the control to an IEnumerable<T> we noticed the following behaviour.
  • Using a FOR loop on the IEnumerable<T> to generate the Tab Items (Tab pages) works fine
  • But setting the Tab Item Content within the same loop for some reason causes some kind of a deferred execution, the contents seem to be set after the tab pages are created (which I assume is related to the load-on-demand feature of the tabstrip)
  • The problem is, the iteration seem to be using the last element in the model to set the content of all the tab pages.

Here is the sample code, could you please direct to the mistake in it or the right method using razor to acheive the same.

@model IEnumerable<KendoMVCExample.Models.CustomerAddress>
...
@(Html.Kendo().TabStrip()
    .Name("CustomerAddressTabStrip")
    .Items(items =>
    {
        foreach (var customer in Model)
        {
            items.Add()
            .Content(@<text> @RenderTableContent(customer) </text>)//<----this fails {last address is repeated on all} 
            .Text(customer.CustomerName); //<----this works fine 
        }        
    }).SelectedIndex(0)
    )
 
     @helper RenderTableContent(KendoMVCExample.Models.CustomerAddress customer)
         {
          <table>
             <tr>
                 <td>
                     @customer.AddressLine1<br />
                     @customer.AddressLine2<br />
                     @customer.AddressLine3<br />
                 </td>
             </tr>
         </table>
    }

No answers yet. Maybe you can help?

Tags
TabStrip
Asked by
Prabhat
Top achievements
Rank 1
Share this question
or