OK我原来的职位:Url.Action处理空值或使用JavaScript客户方值
Url.Action is throwing error CS1026:) expected
得到了回答。但是,我发现模型中我依赖的ID中的一个对象为null。我无法弄清楚如何重写这个工作。
var url = '<%= Url.Action(
"List",
"PlacementAgreementAgencyPlacementAgreementsPlacement",
new {
Domain = "Placement",
Id = Model.Item.PlacementAgreement.PlacementAgreementId,
agencyPlacementAgreementId = Model.Item.AgencyPlacementAgreementId,
Page = Model.PageNo
}) %>';
我需要的是这样的(这是目前说在字符文字的字符太多,我认为可能与单/双引号
var url = '<%= Url.Action(
"List",
"PlacementAgreementAgencyPlacementAgreementsPlacement",
new {
Domain = "Placement",
Id = ' + $("#PlacementAgreementId").val() +',
agencyPlacementAgreementId = ViewData.Model.AgencyPlacementAgreement == null ? 0 : ViewData.Model.AgencyPlacementAgreement.AgencyPlacementAgreementId,
Page = ViewData.Model.PageNo
}
) %>';
也试过:
var url = '<%= Url.Action(
"List",
"PlacementAgreementAgencyPlacementAgreementsPlacement",
new {
Domain = "Placement",
Id = %>' + $("#PlacementAgreementId").val() +'<%=,
agencyPlacementAgreementId = ViewData.Model.AgencyPlacementAgreement == null ? 0 : ViewData.Model.AgencyPlacementAgreement.AgencyPlacementAgreementId,
Page = ViewData.Model.PageNo}) %>';
但是,javascript和url.action的混合只是让我感到困惑。我的问题是,我的ViewData类中没有包含id的属性..但是如果我在页面上查看源代码,我c看到它正在存储在客户端。
任何想法?谢谢!
阿好,谢谢:) - 是的,刚开始让我的头绕着MVC和所有这些使用JQuery/Javascript,所以它不会让我感到惊讶,我没有正确地做到这一点!挑战后端开发者 – Jen 2010-12-22 05:18:24