is there a way in ASP.NET MVC(2) to do something like that:
<table>
<tr>
<% Model.Pager.TemplateNextPage = { %>
<li><a href={link-next-page}>Next</a></li>
<% } %>
<% Model.Pager.TemplatePageNumber = { %>
<li><a href={link-page-number}>{number}</a></li>
<% } %>
<% Model.Pager.TemplatePageNumberActive = { %>
<li>{number}</li>
<% } %>
</tr>
</table>
the general idea is to enable designers to specify templates.
Not like that no. The code betweeen “%>” and “<%” e.g.
… will translate to …
when compiled (ignoring the whitespace in the example). So it does not really work.
What you can do however, is use Asp.Net WebForms controls and create a custom one. It will work within Asp.Net MVC page. Not all features work (e.g. related to form postback), but enough to do what you want.
E.g. a table control is like this:
You could extend that – or create a control from scratch allowing you to create your own TemplateNextPage etc.
…but this is not Asp.Net MVC way – it is the old Asp.Net WebForms way. It just works within Asp.Net MVC pages.
The other option you have is to create your own template engine, but that’s quite a lot of work and I assume the intellisense part is very important to you so it would screw that as well.