1

I have an MVC3 display template that contains a table. The display template will potentially get repeated on the web page. I need to access the table via javascript to show/hide. How can I set the ID attribute of the table html element so that it is not repeated? I could do it manually by grabbing the ID of my Model (like this), but that doesn't seem as clean to me. I'm already using a custom html helper to get html IDs for other input controls, so I'd like to follow that pattern.

Community
  • 1
  • 1
Adam
  • 141
  • 8
  • How do you repeat the template in a page? If you do this within a cycle, you can add the cycle index to a const string. –  Feb 29 '12 at 15:58

1 Answers1

0

Since the html helpers dont deal with table ids, theres nothing wrong with choosing it from your model using

 new {id=Model.YourId}

as the last parameter in the html helpers.

Adam Tuliper
  • 29,982
  • 4
  • 53
  • 71