在ASP.NET MVC中,我試圖創(chuàng)建一個包含錨標(biāo)記的鏈接(即,將用戶定向到頁面以及頁面的特定部分)。我嘗試創(chuàng)建的URL應(yīng)該如下所示:<a href="/category/subcategory/1#section12">Title for a section on the page</a>我的路由設(shè)置為以下標(biāo)準(zhǔn):routes.MapRoute("Default", "{controller}/{action}/{categoryid}"); 我正在使用的動作鏈接語法是:<%foreach (Category parent in ViewData.Model) { %><h3><%=parent.Name %></h3><ul><%foreach (Category child in parent.SubCategories) { %> <li><%=Html.ActionLink<CategoryController>(x => x.Subcategory(parent.ID), child.Name) %></li><%} %></ul><%} %>我的控制器方法如下:public ActionResult Subcategory(int categoryID){ //return itemList return View(itemList);}上面的代碼正確地返回了一個URL,如下所示:<a href="/category/subcategory/1">Title for a section on the page</a>我不知道如何添加#section12部分?!安糠帧币辉~只是我用來拆分頁面部分的約定,而12是子類別的ID,即child.ID。我怎樣才能做到這一點(diǎn)?
在ASP.NET MVC Html.ActionLink中包含錨標(biāo)記
呼啦一陣風(fēng)
2019-11-26 14:13:30