Click here to Skip to main content
15,911,132 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi!

I am facing one issue. I have a login form. When user enter username and password one popup with "terms and condition" will open. When user tick on checkbox and submit, we will check in controller that user's last name is "TBD" or not. If it is "TBD" then we need to open popup with we fill show two dropdown and first name, last name field. Dropdown will be dynamic. On submitting that detail, It will update profile and login user and then redirect on dashboard page.

How can I do it ?
Posted
Comments
Er Daljeet Singh 20-Jul-15 10:16am    
why don't you do that with the help of jQuery.
When a click submit call a jquery function whether lastname is "TBD" or not if it is "TBD" display the popup. and dropdown will be filled with help of Ajax call.

1 solution

Hi Sharma,

I Understood your question. I have tried a lot with Bootstrap and JavaScript for your problem .But I can only achieve the first step(Terms & Condition) pop . the next upadte page of user I did with simple view . Here it is..

View of Login Index
Here I am using Login Button for Displaying PopUp
C#
 @using (Html.BeginForm("Index", "Account", FormMethod.Post))
        {
@Html.TextBoxFor(x => x.UserName, new { @class="input-large span10" , @id="username", @placeholder="type user name" , @autofocus="" });
@Html.TextBoxFor(x => x.UserPwd, new { @class="input-large span10" , @id="password" ,@type="password" , @placeholder="type password"})
	<button  class="btn btn-primary" style="width:100%" data-toggle="modal" data-target="#myModal" >Login</button>
         }


XML
<div id="myModal" class="modal fade" role="dialog">
  <div class="modal-dialog">

    <!--Terms and Conditions-->
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal">&times;</button>
        <h4 class="modal-title">Terms and Conditions</h4>
      </div>
      <div class="modal-body">
        <p>I read terms.</p>
      </div>
      <div class="modal-footer">
        <button type="submit"  class="btn btn-default" >Agree</button>
      </div>
    </div>  </div>
</div>


Post Of Login Index

C#
[HttpPost]
       public ActionResult Index(User user)
       {

           if (true)  //do your stuff insted of true
           {
               return RedirectToAction("Updateuser"); //if true redirect to updateuser page
           }
           else
           return View();
}


User Update Page

HTML
<h2>Updateuser</h2>
  <div class="input text">
                    @Html.DropDownList("UserRole","Select User Type")//Named as ViewBag.UserRole ..see controller code
                    @Html.ValidationMessageFor(model => model.UserRoleID)
                    
                  </div>


User Update Controller

C#
public ActionResult Updateuser()
       {
           ViewBag.UserRole = new SelectList(dbcontext.UserRoles, "ID", "rolename"); // Here I am using user role column in my table.Insted  You can use fristname or lastname 
           return View();
       }
       [HttpPost]
       public ActionResult Updateuser(User user)
       {
           ViewBag.UserRole = new SelectList(dbcontext.UserRoles, "ID", "rolename", user.UserRoleID);
           return View();
       }

If any Doubt please comment . If you got any other way, please comment
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900