且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

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

更新时间:2023-02-12 11:37:02

对于错误检查 - 当前上下文中不存在名称'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[^].