0
私はmvc、c#およびboostrapで作業しています。私のnavbarでは、ログインするためのドロップダウンがあります。これは、右上のFacebookのログインのように配置されています。Dropdown login Mvc
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><img class="img-responsive" src="/images/h-perfil.png" alt="imagen"> perfil <span class="caret"></span></a> <div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;">
<form method="post" action="login" accept-charset="UTF-8">
<input style="margin-bottom: 15px;" type="text" placeholder="Email" id="username" name="username">
<input style="margin-bottom: 15px;" type="password" placeholder="Contraseña" id="password" name="password">
<input class="btn btn-primary btn-block" type="submit" id="sign-in" value="Ingresar">
<label style="text-align:center;margin-top:5px">Registrarme</label>
</form>
</div>
</li>
私はモデルを使用してユーザーにログインする方法を知りました。私は私のモデルを使用するコントローラも持っています。これは私のコントローラです
public ActionResult LogIn(UserModel model)
{
if (!ModelState.IsValid) //Checks if input fields have the correct format
{
return View(model); //Returns the view with the input values so that the user doesn't have to retype again
}
if (credential valids)
{
return RedirectToAction("Index", UserModel); }
この場合、私はブトンをクリックするとログインするようにしたいと思います。おかげ
あなたはUserModelクラスを投稿することができます。基本的には、これらのクラスのプロパティは、入力タグのname属性にマッチする必要があります。送信すると、UserModelクラスが自動的に入力されます –
こんにちは、お返事ありがとうございます。この –
これはモデルです:public class userlogin { public string Email {get;セット; } 公開ストリングパスワード{get;セット; } } だから、それは自動的に入力されると言います。しかし、ボタンをクリックすると、ログインと呼ばれるコントローラーアクションをどのように呼び出すことができますか? もう一度ありがとう!感謝! –