问题
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