In the view layer, go to the detailed page and view shujia 1 ., However, you do not need to add 1 to the modification page. Both call the controller to retrieve a data record from the DB!
On the details page:
"InfoContent", "Activity", new {id = x. NOTICE_ID, browseNum = "add "}
On the modify page:
// Modify
Function Modify (value)
{
Location. href = '/Activity/InfoEdit? P_strNoticeID = '+ value +' & browseNum = '+ unadd;
}
In the Repository
Repository Code
1 public ACT_NOTICE GetSingleActNotice (Guid p_Notice_ID, string browseNum)
2 {
3
4
5 ACT_NOTICE notice = Single (x => x. NOTICE_ID = p_Notice_ID );
6 if (browseNum = "add ")
7 {
8 notice. BROWSE_NUM = notice. BROWSE_NUM + 1;
9}
10
11 SubmitChanges ();
12
13 return notice;
14}
Personal conclusion: the idea of passing parameters extends to controlling the display content by passing different parameters. For example, the same view layer previously created does not display images either, the other does not have any image. we can define a field in viewmodel as a flag.
/// <Summary>
/// Control the parameters of the image displayed on the page
/// </Summary>
Public string showDiv {get; set ;}
In controller
Controller Code
1 /// <summary>
2 // load the announcement list on the Index page
3 /// </summary>
4 /// <returns> </returns>
5 public ActionResult List (int flag)
6 {
7 NoticeViewModel viewModel = new NoticeViewModel ();
8 viewModel = _ noticeLogic. GetNotctForList ();
9
10 // flag = 1 display the picture of the announcement on the index page
11 if (flag = 1)
12 {
13 viewModel. showDiv = "show ";
14}
15
16 return PartialView ("List", viewModel );
17
18}
In this way, you can pass parameters on the Index page.
<Div class = "news">
@ Html. Action ("List", "Notice", new {flag = "1 "})
</Div>
The parameters passed on the other page are different.
At the View layer, the system determines whether to load the display of the div with an image when loading the page.
@ If (Model. showDiv = "show ")
{
Display the image on the index page (parameter 1)
}
Else
{
Do not show images on other pages
}
It can also be extended to viewBag defining a parameter in the controller and passing it to the view layer!