MVC Get Object ID

in the following post: http://bradwilson.typepad.com/blog/2009/10/aspnet-mvc-2-templates-part-4-custom-object-templates.html

<%= Html.Editor(prop.PropertyName) %>

Html.Editor creates a text field with the name generated by MVC. How do I get / access this name? identifier?

So in my code this is generated:

<input type="text" value="Right" name="Template.RightColumn.ContainerName" id="Template_RightColumn_ContainerName">

and I want to generate this:

<div id="Template_RightColumn_ContainerName"></div>

so I need to access the PropertyId. how am i doing this

thank

+3
source share
1 answer

I found him. you can use them:

<%: ViewData.TemplateInfo.HtmlFieldPrefix %>

or

<%: ViewData.TemplateInfo.GetFullHtmlFieldId("HtmlContent") %>

where HtmlContent is the name of your field. the prefix will be generated automatically. thank

+3
source

Source: https://habr.com/ru/post/1783187/


All Articles