asp.net mvc - Creating register method for mvc -


made small front end register page, not sure how register users in mongodb. crud methods written, question how take parameters view's text boxes , parse way data layer? button submit register form:

<div class="form-group">     <input ="submit" id="padding" value="sign up" class="btn btn-primary" />     <a href="home">or cancel</a> </div> 

user controller empty now. not sure if in mvc can use onclick="" method button, not, because there no code behind file. @ first thought somehow should able call padding.click() or whatever method, doesn't seem right way.

use typed data binding posting data view controller like:

poco

 public class registeruser  {     [required]     [emailaddress]     [display(name = "email")]     public string email { get; set; }      [required]     [stringlength(100, errormessage = "the {0} must @ least {2} characters long.", minimumlength = 6)]     [datatype(datatype.password)]     [display(name = "password")]     public string password { get; set; }      [datatype(datatype.password)]     [display(name = "confirm password")]     [compare("password", errormessage = "the password , confirmation password not match.")]     public string confirmpassword { get; set; } } 

register.cstml

<form asp-controller="account" asp-action="register" method="post" class="form-horizontal" role="form"> <h4>create new account.</h4> <hr /> <div asp-validation-summary="validationsummary.all" class="text-danger"></div> <div class="form-group">     <label asp-for="email" class="col-md-2 control-label"></label>     <div class="col-md-10">         <input asp-for="email" class="form-control" />         <span asp-validation-for="email" class="text-danger"></span>     </div> </div> <div class="form-group">     <label asp-for="password" class="col-md-2 control-label"></label>     <div class="col-md-10">         <input asp-for="password" class="form-control" />         <span asp-validation-for="password" class="text-danger"></span>     </div> </div> <div class="form-group">     <label asp-for="confirmpassword" class="col-md-2 control-label"></label>     <div class="col-md-10">         <input asp-for="confirmpassword" class="form-control" />         <span asp-validation-for="confirmpassword" class="text-danger"></span>     </div> </div> <div class="form-group">     <div class="col-md-offset-2 col-md-10">         <button type="submit" class="btn btn-default">register</button>     </div> </div> 

controller's action method

    public iactionresult register(registeruser model)     {             //send data data layer , can inserted mongodb or may in other databases     } 

Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -