如何从视图中调用控制器中的Javascript函数?

编程入门 行业动态 更新时间:2024-10-08 19:44:48
本文介绍了如何从视图中调用控制器中的Javascript函数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 VIEW中有这样的JavaScript函数 getLocation()

function getLocation() { }

我需要在一个类中调用此函数,该类在控制器文件夹

public void 位置() { / / 我需要在这里调用getLocation()JavaScript函数 }

如何我可以调用 JavaScript 函数吗? 我试过 VIEWBAG 它显示错误...

当前上下文中不存在名称VIEWBAG

解决方案

对于错误检查 - 当前上下文中不存在名称'ViewBag' / a> [ ^ ]。 否则请尝试 Google [ ^ ]。

I am having a JavaScript Function getLocation() like this in VIEW

function getLocation() { }

I need to call this Function in a Class Which in Controller Folder

public void Location() { // i need to call getLocation() JavaScript function here }

How can I call my JavaScript function? I tried through VIEWBAG it's showing error...

"The Name VIEWBAG doesn't exist in the current context"

解决方案

For the error check- The name 'ViewBag' does not exist in the current context[^]. Else try some other links from Google[^].

更多推荐

如何从视图中调用控制器中的Javascript函数?

本文发布于:2023-11-17 11:06:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1609814.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视图   函数   器中   Javascript

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!