asp.net mvc - how to display values from database into the layout page in mvc -


here trying make dynamic , editable layout page in mvc.in layout page have logo( presently hard coded). implementing function user can change logo uploading own logo.the path of logo stored in database. example if logo :

<img alt="" src="~/images/w_logo.png" style="border-style: none;" width="115px" height="60px" /> 

i want :

<img alt="" src="@item.logo" style="border-style: none;" width="115px" height="60px" /> 

where 'logo' parameter pass in model.

or

 <img alt="" src="@viewdata["logopath']" style="border-style: none;" width="115px" height="60px" /> 

also if using controller store value how can make runs everytime application starts. example controller:

public actionresult layoutchange() {   --recover path database--   viewdata["logopath"]=path database;   return view(); -- here view layout page } 

any appreciated. thank you.

i recommend try use html.renderaction in _layout.cshtml page. can use specify controller action invoke.

the controller action can 'recover path database' indicated, , pass path partial view contains markup img tag. result of of become part of dynamic markup _layout page.

by taking approach, don't need pass path value _layout page. happens _layout page calls controller (via html.renderaction), , controller figures out path , returns entire img tag markup.

hope helps.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -