Click here to Skip to main content
15,916,951 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, i am looking to open and populate a bootstrap modal, based on the row selected from my html table and the data i have got from my model. I have a button within my html table that will calla JS function and pass the id to it. I am able to get the data back, i just dont know how to populate the model with the json list

thanks

What I have tried:

This is my modal

<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title" id="exampleModalLabel">Change User Deparment</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true"</span>
                </button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label for="Employee Number" class="form-control-label">Employee Number:</label>
                        <input type="text" class="form-control" id="Employee Number">
                    </div>

                    <div class="form-group">
                        <label for="userName" class="form-control-label">User Name:</label>
                        <input type="text" class="form-control" id="userName">
                    </div>

                    <label for="department">Select Department</label>
                    <select class="form-control" id="department">
                        <option>Option1</option>
                        <option>Option2</option>
                        <option>Option3</option>
                    </select>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Send message</button>
            </div>
        </div>
    </div>
</div>


This is JS function and call to get the user details

function editUser(id) {

       //alert(userId);

       $.ajax({
           type: "GET",
           url: '@Url.Action("GetUserDetails", "Admin")',
           contentType: "application/json; charset=utf-8",
           datatype: JSON,
           data: ({ 'Value': id }),
           success: function () {



           },
           error: function () {
               alert(test);
           }
       });
   }
Posted
Comments
Karthik_Mahalingam 28-Nov-17 22:24pm    
populate the value from json success data to the controls which you want to bind.
show the actionmethod.

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