mercredi 20 avril 2016

How to pass values from view to controller in Asp.net

So we have this form in Login.cshtml

<form class="form-horizontal" action="LoginTest">
        <div class="form-group">
            <label for="inputEmail" class="col-sm-2 control-label">Gebruikersnaam</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="inputEmail" placeholder="Email">
            </div>
        </div>
        <div class="form-group">
            <label for="inputPassword" class="col-sm-2 control-label">Wachtwoord</label>
            <div class="col-sm-10">
                <input type="password" class="form-control" id="inputPassword" placeholder="Password">
            </div>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <button type="submit" class="btn btn-primary">Registreer</button>
                <button type="submit" class="btn btn-default">Annuleer</button>
            </div>
        </div>
    </form>

And we have a Logincontroller with the next method LoginTest:

public ActionResult LoginTest(string inputEmail, string inputPassword)
    {
        Response.Write("<script>alert('" + inputEmail + "')</script>");
        return null;
    }

But we are unable to pass the values. Hopefully someone can help us!

Aucun commentaire:

Enregistrer un commentaire