If I have a .net page with bootstrap min and some other js files on the page, it won't run the js files. However, if I move the < form ...> to the end of the file the bootbox javascript works perfectly.
This won't work until you move the form to the end of the file. How come? I want to use a confirm button to make sure the user actually wants to submit the form but I'm starting with this simple example.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css"
rel="stylesheet">
</head>
<body>
<div class="container">
<div class="row">
<div class="span12">
<h2>
Bootbox.Js - Creativity Tuts</h2>
<button class="btn btn-danger">
Alert Box!</button>
</div>
</div>
</div>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js"></script>
<script src="js/bootbox.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('.btn').on('click', function(){
bootbox.prompt("Enter your name", function(res){
if(res == null){
alert("Prompt cancelled by user.");
}else{
alert("Hi: "+res);
}
});
});
});
</script>
<form id="form1" runat="server">
</form>
</body>
</html>
You can add a function to a script at the top of the page "" like the following:
and then capture the post back at the server side by using something like the following:
To assign the javascript function to the asp button ue the following:
Make sure to add "return false" other wise the button will case a post back it self