dimanche 27 décembre 2015

How to pass textbox value to controller in mvc4

How to pass the value on this textbox to controler.

In Index.cshtml file

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
</head>
<body>
    <form>
        <input type="text" id="test" name="test" />
        <input type="submit" value="Click" />
    </form>
</body>

In MyHomeControler file

public ActionResult Index(string test)
{
     string val = test;
     return View();
}

Aucun commentaire:

Enregistrer un commentaire