ASP.NET MVC Displaying multiple partial views inside a folder -


i have mvc application broken down multiple areas. structure this: areas > areaname > views > various view folders

i need add folder inside these view folders called helpfiles making structure areas > areaname > views > various view folders > helpfiles

in layout page, have icon when clicked, call controller method return partial views inside helpfiles folder , display them inside div.

what have done far: have added method basecontroller this:

   public actionresult showhelptext(string viewname)         {             var areaname = controllercontext.routedata.datatokens["area"];             var foldername = "~"+ areaname + viewname + "helpfiles/";             viewbag.partials = ????             return view();         } 

on returning view code this:

@foreach (string partial in viewbag.partials) {     //html.renderpartial(partial);     @html.partial(partial) } 

my problem not able figure way views folder.

i realize not ideal way of doing this, text should come database etc, due cms service tie in, stuck structure now.

any or pointers appreciated.

thanks

untested code, might need make little changes in order make work.

//replace `~/content/helpfiles` real path. viewbag.partials = directory.enumeratefiles(server.mappath("~/content/helpfiles")).select(i => path.getfilename(i)); 

view:

@foreach (string partial in (ienumerable<string>)viewbag.partials) {     @html.partial(partial) } 

Comments

Popular posts from this blog

gridview - Yii2 DataPorivider $totalSum for a column -

java - Suppress Jboss version details from HTTP error response -

Sass watch command compiles .scss files before full sftp upload -