第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機(jī)立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

在ASP.NET MVC Html.ActionLink中包含錨標(biāo)記

在ASP.NET MVC Html.ActionLink中包含錨標(biāo)記

呼啦一陣風(fēng) 2019-11-26 14:13:30
在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)?
查看完整描述

3 回答

?
汪汪一只貓

TA貢獻(xiàn)1898條經(jīng)驗 獲得超8個贊

有一些采用片段參數(shù)的ActionLink重載。將“ section12”作為片段傳遞將使您獲得所要遵循的行為。


例如,調(diào)用LinkExtensions.ActionLink方法(HtmlHelper,字符串,字符串,字符串,字符串,字符串,字符串,字符串,對象,對象):


<%= Html.ActionLink("Link Text", "Action", "Controller", null, null, "section12-the-anchor", new { categoryid = "blah"}, null) %>


查看完整回答
反對 回復(fù) 2019-11-26
  • 3 回答
  • 0 關(guān)注
  • 530 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號