views:

299

answers:

2

Ok, so, that title is a mouthfull... But, I reckon you understand what I'm trying to do.

I have a page which contains the jquery tabs control, and I render the different tabs by looping through my model. Now, the divs (that are "linked" to those tabs) are also created with the same loop. Hence I have equal tabs + divs connected to those tabs.

The problem is, that it's only the first RenderAction gets called, all the others are just the same.

The code that loops the renderactions:

foreach (var domain in Model.Domains)
{ %>
    <%= String.Format(@"<div id=""domain_{0}"">", domain.ID)%>
        <%= Html.Encode(domain.ID) %>
        <% Html.RenderAction("DomainView", "Person", new { domainid = domain.ID }); %>

    </div>
<% } %>

So, each div has an id of "domain_NUMBER" where of course the number is looped. And the renderaction calls the "DomainView" Action in my controller that takes a "domainid" parameter.

Optimistically, I thought this would work, but, I guess I'm wrong...

A: 

If I understand you correctly, you're getting, say, 3 divs, but they're all the same.

By same you could mean 2 things:

1) If you mean that all the divs are named "div_1", then you have 3 domains with the same domainid and there's an issue with the way you add domains to your model

2) If you mean that the divs are named differently but the content is the same,

You need to set a breakpoint at the DomainView action of the Person controller. This will let you see what domainid is being passed in. Because the code itself looks fine. The issue probably has to do with routing. For example, the DomainView action takes an ID parameter but you're passing DOMAINID so ID is just defaulting to 0 which means all the divs have the same content

statichippo
Well, by "the same", I mean that the dives are named differently, AND the content is different YET it's the same usercontrol (partial view).So, the content is always the same partial view, but that partialview is loaded with a different parameter each time.So, in a way, the content is different.For now though, I will do as you pointed out, and just check IF it actually passes a different domainid each time or not.
Tim Geerts
After some debugging, I noticed that I was constantly getting domainid=1 in my controller. This strikes me as odd seeing I print out the parameter before passing it (see code sample in original post) and on my screen, I can see 1, 2, 3, 4, ...
Tim Geerts
There might be a caching issue here. Can you post the Route that this is mapping to? Does the domainid get passed to the Controller as a QueryString or as part of the URL (ie "/Person/DomainView/?domainid=123" vs "/Person/DomainView/123")?
statichippo
A: 

Statichippo, indeed, it had something to do with my routevalues.

Seeing I'm not the developer that made the routemap, I "forgot" to check these. Once I formulated my URL's to use querystring, all worked well!

In the current project, it's not allowed to add/modify route values, so I had to find a workaround.

Tim Geerts