【发布时间】:2017-05-14 20:42:45
【问题描述】:
我正在通过 ViewData 从控制器向 html 页面发送一个文件路径(字符串),我想在我的 javascript 中访问该字符串,使用它,在 javascript 中运行一些算法,然后使用结果来使用它们并在相同的 html 页面。
HTML
</head>
<body>
<div id="mychart"></div>
<script>
var path=@ViewData["path"];
//some javascript logic with the string path of the file.
//using results for output chart of id 'mychart'
</script>
</body>
</html>
控制器动作代码:
public IActionResult CellResult(string outputpath)
{
ViewData["path"] = outputPath;
return View();
}
【问题讨论】:
标签: javascript html asp.net viewdata