我在 MVC c# Razor 视图中有以下代码:
@{string url = "/Projects/_MonthRangesScriptsPartial";}
@using (Ajax.BeginForm(
"_MonthRanges",
"Projects",
new { id = ViewBag.InputResourceID },
new AjaxOptions {
HttpMethod = "POST",
UpdateTargetId = "MonthRanges",
InsertionMode = InsertionMode.Replace,
OnComplete = "updategraphArrayScript(@url,@ViewBag.InputResourceID)"
}))
该代码几乎可以完美运行,但我想将 c# 变量解析为它们在 OnComplete 行中的值。
也就是说,Razor 引擎应该将代码解析为(例如):
<form action="/Projects/_MonthRanges/55"
data-ajax="true" data-ajax-complete="updategraphArrayScript(/Projects/assets,55)"
...>
而不是:
<form action="/Projects/_MonthRanges/55"
data-ajax="true" data-ajax-complete="updategraphArrayScript(@url,@ViewBag.InputResourceID)"
...>