Find Relevant MVC Template

懵懂的女人 提交于 2019-12-25 02:06:55

问题


My main View is calling Template view is as below:

  <%: Html.EditorFor(model => model.AuthorizedCreditCard)%>

My Templates are as below :

Both above templates are consuming same model (i.e. model.AuthorizedCreditCard).

So My question is How to find which Template is runing when I call EditorFor.

I would like to have a technical explanation.


回答1:


By default, the EditorFor helper uses the template whose name matches the name of the type being edited. So, if your AuthorizedCreditCard is an instance of something called AuthorizedCreditCard, then it should use AuthorizedCreditCard.ascx. If you want to use something else, you can pass the name of the template you want as a string, thus:

<%: Html.EditorFor(model => model.AuthorizedCreditCard, "AuthorizedCreditCardEditer")%>


来源:https://stackoverflow.com/questions/15809862/find-relevant-mvc-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!