我正在尝试使用以下结构/代码创建一个链接按钮:
<%:school => string.Format("<a class='add' href='{0}' title='Add {1} to {4}'><img class='pic2' alt='{2}' src='{3}'/></a>",
Url.Action("AddSchoolToParty", "PartySchool",
new { partyId = Model.PartyId, schoolId = school.SchoolId }),
School.EntityName, string.Empty,
Url.Content("~/Content/images/addImage.png"),
School.EntityName)%>
我得到的错误是:
CS1660:无法将 lambda 表达式转换为类型“字符串”,因为它不是委托类型
这也是用我拥有的信息创建链接的正确格式吗?
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<Kids.MVC.Models.ViewModels.SchoolFormViewModel>" %>
<%@ Import Namespace="Kids.Resources" %>
<%@ Import Namespace="Kids.Resources.Entities" %>
<%@ Import Namespace="MvcContrib.Pagination" %>
<%@ Import Namespace="MvcContrib.UI.Grid" %>
<%@ Import Namespace="MvcContrib.UI.Pager" %>
<%: Html.ValidationSummary(true, Message.ValidationErrorSummary, new{@class= "error"}) %>
<%=Html.DatePickerEnable() %>
这是我在不同页面中使用的格式,这是我想在没有列和 string.format 的标签中重写的按钮链接 - 我想知道重写此链接的正确方法。
column.For(
school =>
string.Format("<a class='add' href='{0}' title='Add {1} to {4}'><img class='pic2' alt='{2}' src='{3}'/></a>",
Url.Action("AddSchoolToParty", "PartySchool",
new { partyId = Model.PartyId, schoolId = school.SchoolId }),
School.EntityName, string.Empty,
Url.Content("~/Content/images/addImage.png"),
School.EntityName)).Encode(false).Sortable(false);