简体   繁体   中英

What is the best way to store tooltip titles to be edited in MVC?

I'm currently building a form in ASP.NET MVC 4 . I know how to make the tooltips and they work just fine, BUT...

The application has an admin panel, where I want to be able to change the title for each tooltip , so the customer can change these values themself. I have 14 properties in a viewmodel which each needs a tooltip.

What would be the best possible way to store these titles?

I'm using EF6 and guess they should be stored in the DB , but with relations to underlying properties or not? And if YES then how?

I tried to hardcode the titles in the viewmodel and present it like @Model.PropertyTooltip , but MVC only renders properties { get; set; } and not fields ( prop = "tooltiptext"; ) as far as I know.

Please correct me if I'm wrong!

EDIT: Example of binding

<a data-toggle="tooltip" title="@Model.NameTooltip"><span class="glyphicon glyphicon-info-sign"></span></a>

Still new to asking questions here, so post feedback is appreciated.

Thanks

The first thing that came to my mind on reading your question is that it looks like a problem that can be better solved by using Resource files (.resx).

Create a table that stores these key values. Whenever a user updates a value, you would need to regenerate the resource package on the fly.

In your view code, you just mention the key in your anchor tags the corresponding value can be pulled from the resx file.

If you are willing to go down that route then I can try to expand on this answer.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM