---
title: "How to call javascript function in mvc4 controller?"  
description: "How to call javascript function in mvc4 controller?"  
author: "Gaurpriya Bishnoi"  
published: 2015-07-03  
updated: 2015-07-06  
canonical: https://www.mindstick.com/forum/23318/how-to-call-javascript-function-in-mvc4-controller  
category: "asp.net mvc"  
tags: ["jquery", "javascript"]  
reading_time: 1 minute  

---

# How to call javascript function in mvc4 controller?

**[javascript](https://www.mindstick.com/articles/874/how-to-create-watermark-text-for-textbox-by-using-javascript) [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii):**

```
<script type="text/javascript">    function test(pa)    {        alert(pa);    }</script>
```

**[index](https://www.mindstick.com/blog/198/index-in-sql-server).cshtml**

```
@using(Html.BeginForm("Index","Home"))
    {
    <button type="submit">Hello</button>
    }
```

**[Controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)**\

```
public class HomeController : Controller, IJavaScriptModelAware
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            this.AddJavaScriptFunction("test", PageLoadEvent.Ready, null, "hello");
            return View();
        }

    }
```

I am fallow javascript [model](https://yourviews.mindstick.com/view/81334/america-is-reopening-after-corona-lockdown-but-on-swedish-model)\
[install](https://www.mindstick.com/articles/12876/the-top-5-reasons-to-buy-and-install-a-tonneau-cover) this\
Install-[Package](https://www.mindstick.com/blog/12619/tips-for-finding-the-right-package-when-you-buy-instagram-followers) JSM.MVC4\
what is problem i can't understand please [solve this problem](https://answers.mindstick.com/qa/94681/my-google-assistant-shows-completely-different-search-results-from-what-i-ask-how-can-i-solve-this-problem)

## Replies

### Reply by Gaurpriya Bishnoi

i am not want to return json return only viewand waht is SomeView please discribe this

### Reply by greg DORIAN

```
[HttpGet]public ActionResult SayHello(){    var personSaluteU = SomeView.GetPerson();    return Json(person, JsonRequestBehavior.AllowGet);}function GetPerson() { $(“#Button1″).click(function(otro){                alert(“Your name: ” + $(“#TextBox1″).val());            });}
```

maybe this help ful


---

Original Source: https://www.mindstick.com/forum/23318/how-to-call-javascript-function-in-mvc4-controller

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
