HOW TO CALL JAVASCRIPT FUNCTION IN MVC4 CONTROLLER?

Gaurpriya Bishnoi

Total Post:7

Points:49
Posted by  Gaurpriya Bishnoi
 13448  View(s)
Ratings:
Rate this:
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
  1. greg DORIAN

    Post:1

    Points:7
    Re: How to call javascript function in mvc4 controller?

    [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

  1. Gaurpriya Bishnoi

    Post:7

    Points:49
    Re: How to call javascript function in mvc4 controller?

    i am not want to return json return only view

    and waht is SomeView please discribe this

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!