This is my action method for new user registration and update user
- public ActionResult SignUp(User obj)
- {
- if(obj != null)
- {
- return View(obj);
- }
- else
- {
- return View();
- }
- }
This is view page
- @model nsroute.BusinessObject.UserBO
- @{
- ViewBag.Title = "Sign Up";
- }
- class="login">
- class="wrapper wrapper-login">class="container container-login animated fadeIn">
class="logo" src="~/Content/assets/img/logo.jpg" />
- @using (Html.BeginForm("SignUp", "Account", FormMethod.Post))
- {
class
="text-center">Registerclass="login-form">class="form-group">- @Html.HiddenFor(model=>model.UserId)
- @Html.LabelFor(model => model.FullName, new { @class = "placeholder" })
- @Html.TextBoxFor(model => model.FullName, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.FullName, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.UserEmail, new { @class = "placeholder" })
- @Html.TextBoxFor(model => model.UserEmail, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.UserEmail, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.Password, new { @class = "placeholder" })
- @Html.PasswordFor(model => model.Password, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.Password, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.ConfirmPassword, new { @class = "placeholder" })
- @Html.PasswordFor(model => model.ConfirmPassword, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.ConfirmPassword, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.CompleteAddress, new { @class = "placeholder" })
- @Html.TextBoxFor(model => model.CompleteAddress, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.CompleteAddress, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.City, new { @class = "placeholder" })
- @Html.TextBoxFor(model => model.City, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.City, null, new { @class = "text text-danger" })
class="form-group">- @Html.LabelFor(model => model.State, new { @class = "placeholder" })
- @Html.TextBoxFor(model => model.State, new { @class = "form-control" })
- @Html.ValidationMessageFor(model => model.State, null, new { @class = "text text-danger" })
class="form-group form-action-d-flex mb-3">- "submit" value="Submit" class="btn btn-primary w-100 fw-bold" />
class="login-account">- class="msg">Already a Member ,
- "@Url.Action("Login", "Account")" id="show-signup" class="link">Login Here !
- }
when clicking on update button the id including all other values is passed it is showing in the url also
but getting this error
The model item passed into the dictionary is of type 'nsroute.DataAccess.User', but this dictionary requires a model item of type 'nsroute.BusinessObject.UserBO'.
Junaid MuslaPosted Oct 1, 2020, 7:06 AM
So Yash, basically the action ActionResult SignUp(User obj) has an input model(parameter) of type User which is defined in the namespace nsroute.DataAccess.
@model nsroute.BusinessObject.UserBO
which is an issue.
So either pass UserBO as a parameter to your view:
Change your view's model to:
Jignesh KumarPosted Oct 1, 2020, 8:51 AM
Sachin SinghPosted Oct 1, 2020, 7:48 AM