How to Add Bootstrap Modal View in Asp.Net Webform Tutorial
This is a short tutorial of how to create/add a simple Bootstrap Modal View into an ASP.Net project. The tutorial can help you to know what are the requirements and how it is being done. This will also helps you to understand how to add/convert the modal view into asp.net project.
Here, I will show the code that present a modal button which fires/open the modal when clicked. In the same page the modal interface scripts are also included.
Index/Main Page
The following script is the code for the main script which is the main interface of the simple project that contains the Interface Script and Modal Interface Script. It also includes the script that loads the Bootstrap library and other links.
- <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ModalView.aspx.cs" Inherits="Crud_Operation.ModalView" %>
- <!DOCTYPE html>
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <link rel="stylesheet" type="text/css" href="modal.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css">
- <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css">
- </head>
- <body>
- <form id="form1" runat="server">
- <div class="container">
- <button type="button" class="btn btn-danger" data-toggle="modal" data-target="#form">
- See Modal with Form
- </button>
- </div>
- <div class="modal fade" id="form" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true" style="display: none;">
- <div class="modal-dialog modal-dialog-centered" role="document">
- <div class="modal-content">
- <div class="modal-header border-bottom-0">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close">
- </button>
- </div>
- <form>
- <div class="modal-body">
- <div class="form-group">
- <input type="email" class="form-control" id="email1" aria-describedby="emailHelp" placeholder="Enter email">
- </div>
- <div class="form-group">
- <input type="password" class="form-control" id="password1" placeholder="Password">
- </div>
- <div class="form-group">
- <input type="password" class="form-control" id="password2" placeholder="Confirm Password">
- </div>
- </div>
- <div class="modal-footer border-top-0 d-flex justify-content-center">
- </div>
- </form>
- </div>
- </div>
- </div>
- <div>
- </div>
- </form>
- </body>
- </html>
DEMO VIDEO
I hope this tutorial will help you with what you are looking for. Next post I will add the project for complete crud operation, and we will add data into the database using the same modal view.
Happy Coding!!
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.
Add new comment
- 4442 views