A Web site, a list of articles or news lists, need to place a small new.gif in front of the title, marked as the latest news or article. The practice of insus.net today is to implement this functionality in an ASP. NET MVC application. The plan is implemented using three different methods.
Start with the database, create a table, add some data, and create a stored procedure that gets all the records:
In an MVC application, create the model:
Create an entity that interacts with the data to obtain information:
In control, create an action:
In the following directory, create the view:
Newslist.cshtml View:
This is a way of looking at the effect:
The second approach, Insus.net, uses a HtmlHelper extension method to implement this image:
In the view, you need to modify the code a little bit:
At run time, the effect is displayed just as the first method renders.
And the third method? Can be implemented using a partial view.
To use this partial view, you need to modify the newslist.cshtml view:
Run the results, all the same, you think which method is good and convenient, whichever you choose.