Click here to Skip to main content
15,941,071 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello Guyz,

I am trying to Open a Bootstrap Modal Window in MVC.

But no success yet.

Below is the jQuery code:

XML
<script type="text/javascript">
       $(document).ready(function () {
           $('.viewInfo').click(function () {

               debugger;

               var url = $(this).attr('href');//$('#signup').data('url');

               $.get(url, function (data) {
                   $('#signup').html(data);

                   $('#signup').modal('show');
               });
           });
       });
   </script>


Partial View :

XML
<div id="myModal" tabindex="-1" style="background-color: #FFFFFF;margin: 10% auto 0;width: 50%;" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel">Modal header</h3>
    </div>
    <div class="modal-body">
        <p>One fine body…</p>
    </div>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>
    </div>
</div>



Action Method:

XML
public ActionResult ShowDialog(int iBrandID = 0)
       {
           var data = (from tbl in oDataContext.tblVehicleBrands
                       where tbl.BrandID == iBrandID
                       select tbl).SingleOrDefault<tblVehicleBrand>();

           return PartialView(data);

       }



@Html.ActionLink("View Info", "ShowDialog", "Home", new { id = @vehiclBrand.BrandID }, new { @class = "viewInfo"})

Modal is opening as full page.

Any help would be appreciated.


Thanks,

Vinay
Posted

Change your partial view

<div id="myModal" ... > to <div id="signup" ... >
 
Share this answer
 
v2
 
Share this answer
 
Managed to sort out....!!!
Thanks Akinmade and Abhishek for replying...!!!
 
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