You need to add a bootstrap reference when you use it, otherwise you won't achieve it.
<! DOCTYPE html>
<meta name= "viewport" content= "Width=device-width"/>
<title>Index</title>
Note the reference order here
<link href= "~/css/bootstrap.min.css" rel= "stylesheet"/> <script src= "~/js/jquery.min.js" ></ script> <script src= "~/js/bootstrap.min.js" ></script>
This is done using AJAX login
<script>function Submita () {$.ajax ({type:'Post', datatype:'JSON', URL:'/home/login', data: {Email: $ ('#txtemail'). Val (), PWD: $ ('#txtpwd'). Val ()}, Success:function (data) {if(Data >0) {alert ('Login Successful'); varm = document.getElementById ("D"); M.innerhtml="<div style= ' float:right ' id= ' d ' ><ul class= ' nav navbar-nav ' ><li class= ' dropdown active ' ><a href= ' # ' class= ' dropdown-toggle ' data-toggle= ' dropdown ' >sa<b class= ' caret ' ></b></a><ul class= ' Dropdown-menu ' ><li><a href= ' # ' > Set </a></li><li><a href= '/Home/zhuxiao ' > Exit </a></li></ul></li></ul></div>"; $("#myModal"). Modal ("Hide"); } Else{alert ('Logon Failure'); }}, Error:function (err) {alert ( c7>'Error') } }) } </script>
<style>
. navbar{
Color:white
}
</style>
<body>
Click the login button in the navigation
<navclass= "NavBar Navbar-default"role= "Navigation"style= "<div class="Navbar-header "> <aclass= "Navbar-brand"href="#"style= "margin-bottom:20px;"> <imgsrc= "~/logo-transparent.png" /> </a> </Div> <Div> <ulclass= "Nav navbar-nav"> <Liclass= "Dropdown"> <ahref="#"class= "Dropdown-toggle"Data-toggle= "Dropdown">Course<bclass= "Caret"></b></a> <ulclass= "Dropdown-menu"> <Li><ahref="#">All courses</a></Li> <Li><ahref="#">Learning Path</a></Li> </ul> </Li> <Li> <ahref="#">Question</a> </Li> <Li><ahref="#">Training camp</a></Li> <Li><ahref="#">Member</a></Li> </ul> <Divstyle= "float:right; position:absolute;right:0;top:15px;"ID= "D"> <aclass= "BTN"Data-toggle= "Modal"Data-target= "#myModal">Login</a> <a>Registered</a> </Div> </Div> </nav>
Modal code
<Divclass= "Modal Fade"ID= "Mymodal"TabIndex= "-1"role= "Dialog"Aria-labelledby= "Mymodallabel"Aria-hidden= "true"> <Divclass= "Modal-dialog"> <Divclass= "Modal-content"> <h4class= "Modal-title"style= "Text-align:center"ID= "Mymodallabel">Login</h4> <Divclass= "Modal-header"> <Buttontype= "button"class= "Close"Data-dismiss= "Modal"Aria-hidden= "true"> × </Button> </Div> <form> <Divclass= "Modal-body"style= "Text-align:center">Email:<inputtype= "Email"ID= "Txtemail"Required/><BR/>Password:<inputtype= "Password"ID= "Txtpwd"Required/> </Div> <Divclass= "Modal-footer"style= "Text-align:center"> <inputtype= "Submit"onclick= "Submita (); return false;"ID= "BTN"class= "Btn btn-primary"> </Div> </form> </Div> </Div> </Div>
</body>
Modal simple case of bootstrap