如何从视图中调用控制器中的Javascript函数? [英] How to call Javascript function in controller from view?

查看:84
本文介绍了如何从视图中调用控制器中的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函数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆