加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net – 如何从Controller设置@ Html.ActionLink的动态标题?

发布时间:2020-12-15 23:11:12 所属栏目:asp.Net 来源:网络整理
导读:我有 @Html.ActionLink("Remove 1034,1035,1036","RemoveSelected") 现在我想从Controller设置每个id 例如: @Html.ActionLink(ViewBag.RemoveSelectedTitle,"RemoveSelected") //this is not work// GET: /TabMaster/ public ActionResult Index() { ViewBa
我有
@Html.ActionLink("Remove 1034,1035,1036","RemoveSelected")

现在我想从Controller设置每个id

例如:

@Html.ActionLink(ViewBag.RemoveSelectedTitle,"RemoveSelected") //this is not work

// GET: /TabMaster/
        public ActionResult Index()
        {
            ViewBag.RemoveSelectedTitle = "100,101,102";
            return View(_tabmasterService.GetTabMasterList(10,1));
        }

解决方法

您需要将RemoveSelectedTitle转换为字符串.当您使用Viewbag时,这是一个动态对象,并且不知道RemoveSelectedTitle是一个字符串. ActionLink应该是这样的:
@Html.ActionLink((string)ViewBag.RemoveSelectedTitle,"RemoveSelected")

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读