forum

home / developersection / forums / how to call javascript function in mvc4 controller?

How to call javascript function in mvc4 controller?

Gaurpriya Bishnoi 16412 03-Jul-2015

javascript code:

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

index.cshtml

@using(Html.BeginForm("Index","Home"))

    {
    <button type="submit">Hello</button>
    }

Controller

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

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

    }

I am fallow javascript model
install this
Install-Package JSM.MVC4
what is problem i can't understand please solve this problem


Updated on 06-Jul-2015
Can you answer this question?

Answer

2 Answers

Liked By