Home > DeveloperSection > Forums > How to call javascript function in mvc4 controller?
Gaurpriya Bishnoi
Gaurpriya Bishnoi

Total Post:7

Points:49
Posted on    July-03-2015 1:37 AM

 ASP.NET MVC JQuery  JavaScript 
Ratings:


 2 Reply(s)
 8249  View(s)
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


greg DORIAN
greg DORIAN

Total Post:1

Points:7
Posted on    July-03-2015 9:19 AM

[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

Gaurpriya Bishnoi
Gaurpriya Bishnoi

Total Post:7

Points:49
Posted on    July-06-2015 3:09 AM

i am not want to return json return only view
and waht is SomeView please discribe this

Don't want to miss updates? Please click the below button!

Follow MindStick