0

On a page I use a jQuery UI tabs. In several tabs, some part are the same, then I create a partial view. This partial view is call several time on the same page because tabs are divs on the same page. Then I have to make a difference between control.

In the partial view, I have this : @Html.TextBoxFor("MyControl");

I'd like to tab0 give to this control : tabs0MyControl

I'd like to tab1 give to this control : tabs1MyControl

I need make the difference between because I do some action with jQuery after.

Steve
  • 8,469
  • 1
  • 26
  • 37
TheBoubou
  • 19,487
  • 54
  • 148
  • 236

2 Answers2

0

Perhaps someone else knows better, but I don't think it's possible without creating your own Helper Methods to render those textboxes. Such helpers would probably look like

@Html.TabTextBoxFor("MyControl", tabId)

Anyway, consider the fact that having multiple elements with the same name in the page, would cause jQuery to return an array when accessing that name. You can easily utilize it to access the appropriate part of the array in your code.

Moshe
  • 2,638
  • 2
  • 28
  • 32
0

You need to pass a prefix to the partial view, then use that to compose the ids, see these questions:

Partial View with parametrized prefix for controls names

ASP.NET MVC partial views: input name prefixes

Community
  • 1
  • 1
BlackTigerX
  • 6,006
  • 7
  • 38
  • 48