How can I use an anchor tag to open a modal page?

I have an anchored tag in my navbar that I would like to use to open a modal form as a sub page. I used the standard W3Schools form to test it out. However nothing opens, I know it has something to do with the href. But I'm just not sure how to specify the href to the modal form.

HTML:

 <div class="collapse navbar-collapse" id="PageNavigation">
                        <ul class="nav navbar-nav" id="NavigationLinks">
                            <li>@Html.ActionLink("DASHBOARD", "Index", "Dashboard", "", new { @class = "MainNavText", @id = "MainNavDashboard" })</li>
                            <li>@Html.ActionLink("EXPORT", "Index", "Dashboard", "", new { @class = "MainNavText", @id = "MainNavExport" })</li>
                            <li><a data-target="#myModel" data-toggle="modal" class="MainNavText" id="MainNavHelp">HELP</a></li>
                         </ul>
                        @Html.Partial("_LoginPartial")
                    </div>

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

            <!-- Modal content-->
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal">&times;</button>
                    <h4 class="modal-title">Modal Header</h4>
                </div>
                <div class="modal-body">
                    <p>Some text in the modal.</p>
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                </div>
            </div>

        </div>
    </div>

      

How can i do this?

+3


source to share


1 answer


Found.

<li>
    <a data-target="#myModal" data-toggle="modal" class="MainNavText" id="MainNavHelp" 
       href="#myModal">HELP</a>
</li>

      



You just need to set the id to href

.

+11


source







All Articles