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:

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


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

               $.get(url, function (data) {


Partial View :

<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 class="modal-body">
        <p>One fine body…</p>
    <div class="modal-footer">
        <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
        <button class="btn btn-primary">Save changes</button>

Action Method:

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.



Change your partial view

<div id="myModal" ... > to <div id="signup" ... >
Share this answer
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