asp.net mvc - cannot use Html helper in partial view? -
background
i have following method in controller
[httpget] public actionresult getmodulepropertyname(string moduletypevalue) { var modulekindid = _repository.getmodulekindid(moduletypevalue); var modulepropertynames = _repository.getmodulekindpropertynames(modulekindid); return partialview(modulepropertynames); }
modulepropertynames
may contain list of strings
of null.
what want do
i want create text box each string passed partial view placeholder or label string, user type text there later retrieve.
what i've been doing
i'm doing following right now, says cannot resolve symbol textboxfor
@foreach (var names in model) { <div class="input-block-level">@html.textboxfor(names, new {@placeholder = names})</div> }
here web.config of area i've been working on
<?xml version="1.0"?> <configuration> <configsections> <sectiongroup name="system.web.webpages.razor" type="system.web.webpages.razor.configuration.razorwebsectiongroup, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <section name="host" type="system.web.webpages.razor.configuration.hostsection, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" /> <section name="pages" type="system.web.webpages.razor.configuration.razorpagessection, system.web.webpages.razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" requirepermission="false" /> </sectiongroup> </configsections> <system.web.webpages.razor> <host factorytype="system.web.mvc.mvcwebrazorhostfactory, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" /> <pages pagebasetype="system.web.mvc.webviewpage"> <namespaces> <add namespace="system.web.mvc" /> <add namespace="system.web.mvc.ajax" /> <add namespace="system.web.mvc.html" /> <add namespace="system.web.optimization"/> <add namespace="system.web.routing" /> </namespaces> </pages> </system.web.webpages.razor> <appsettings> <add key="webpages:enabled" value="false" /> </appsettings> <system.web> <httphandlers> <add path="*" verb="*" type="system.web.httpnotfoundhandler"/> </httphandlers> <!-- enabling request validation in view pages cause validation occur after input has been processed controller. default mvc performs request validation before controller processes input. change behavior apply validateinputattribute controller or action. --> <pages validaterequest="false" pageparserfiltertype="system.web.mvc.viewtypeparserfilter, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" pagebasetype="system.web.mvc.viewpage, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" usercontrolbasetype="system.web.mvc.viewusercontrol, system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35"> <controls> <add assembly="system.web.mvc, version=4.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35" namespace="system.web.mvc" tagprefix="mvc" /> </controls> </pages> </system.web> <system.webserver> <validation validateintegratedmodeconfiguration="false" /> <handlers> <remove name="blockviewhandler"/> <add name="blockviewhandler" path="*" verb="*" precondition="integratedmode" type="system.web.httpnotfoundhandler" /> </handlers> </system.webserver> </configuration>
html.textboxfor
taking expression<func<list<model>>, tproperty>
first argument. try use way:
@for (int = 0; < model.count; i++) { @html.textboxfor(name => name[i], new {@placeholder = names}) }
or use html.textbox()
:
@for (int = 0; < model.count; i++) { @html.textbox("name[" + + "]", model[i], new {@placeholder = names}) }
Comments
Post a Comment