• We just launched and are currently in beta. Join us as we build and grow the community.

How to Add Bootstrap Modal View in Asp.Net Webform Tutorial

RothschiId

Grin Collector
R Rep
0
0
0
Rep
0
R Vouches
0
0
0
Vouches
0
Posts
86
Likes
57
Bits
2 MONTHS
2 2 MONTHS OF SERVICE
LEVEL 1 300 XP
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.

  1. <%@ Page Language

    =

    "C#"

    AutoEventWireup=

    "true"

    CodeBehind=

    "ModalView.aspx.cs"

    Inherits=

    "Crud_Operation.ModalView"

    %>

  2. <!DOCTYPE html>

  3. <html

    xmlns=

    "http://www.w3.org/1999/xhtml"

    >
  4. <head

    runat=

    "server"

    >
  5. <title

    ></

    title

    >
  6. <link

    rel

    =

    "stylesheet"

    type

    =

    "text/css"

    href

    =

    "modal.css"

    >
  7. <link

    rel

    =

    "stylesheet"

    href

    =

    "https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.1.2/css/bootstrap.min.css"

    >
  8. <link

    rel

    =

    "stylesheet"

    href

    =

    "https://use.fontawesome.com/releases/v5.3.1/css/all.css"

    >
  9. <script

    src

    =

    "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"

    integrity=

    "sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ=="

    crossorigin=

    "anonymous"

    referrerpolicy=

    "no-referrer"

    ></

    script

    >
  10. <script

    src

    =

    "https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"

    ></

    script

    >
  11. <script

    src

    =

    "https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"

    ></

    script

    >
  12. </

    head

    >
  13. <body

    >
  14. <form

    id

    =

    "form1"

    runat=

    "server"

    >

  15. <div

    class

    =

    "container"

    >
  16. <button

    type

    =

    "button"

    class

    =

    "btn btn-danger"

    data-toggle=

    "modal"

    data-target

    =

    "#form"

    >
  17. See Modal with Form
  18. </

    button

    >
  19. </

    div

    >
  20. <div

    class

    =

    "modal fade"

    id

    =

    "form"

    tabindex

    =

    "-1"

    role=

    "dialog"

    aria-labelledby=

    "exampleModalLabel"

    aria-hidden=

    "true"

    style

    =

    "display: none;"

    >
  21. <div

    class

    =

    "modal-dialog modal-dialog-centered"

    role=

    "document"

    >
  22. <div

    class

    =

    "modal-content"

    >
  23. <div

    class

    =

    "modal-header border-bottom-0"

    >
  24. <h5

    class

    =

    "modal-title"

    id

    =

    "exampleModalLabel"

    >

    Create Account</

    h5

    >
  25. <button

    type

    =

    "button"

    class

    =

    "close"

    data-dismiss=

    "modal"

    aria-label

    =

    "Close"

    >
  26. <span

    aria-hidden=

    "true"

    >

    ×</

    span

    >
  27. </

    button

    >
  28. </

    div

    >
  29. <form

    >
  30. <div

    class

    =

    "modal-body"

    >
  31. <div

    class

    =

    "form-group"

    >
  32. <label

    for

    =

    "email1"

    >

    Email address</

    label

    >
  33. <input

    type

    =

    "email"

    class

    =

    "form-control"

    id

    =

    "email1"

    aria-describedby=

    "emailHelp"

    placeholder=

    "Enter email"

    >
  34. <small

    id

    =

    "emailHelp"

    class

    =

    "form-text text-muted"

    >

    Your information is safe with us.</

    small

    >
  35. </

    div

    >
  36. <div

    class

    =

    "form-group"

    >
  37. <label

    for

    =

    "password1"

    >

    Password</

    label

    >
  38. <input

    type

    =

    "password"

    class

    =

    "form-control"

    id

    =

    "password1"

    placeholder=

    "Password"

    >
  39. </

    div

    >
  40. <div

    class

    =

    "form-group"

    >
  41. <label

    for

    =

    "password1"

    >

    Confirm Password</

    label

    >
  42. <input

    type

    =

    "password"

    class

    =

    "form-control"

    id

    =

    "password2"

    placeholder=

    "Confirm Password"

    >
  43. </

    div

    >
  44. </

    div

    >
  45. <div

    class

    =

    "modal-footer border-top-0 d-flex justify-content-center"

    >
  46. <button

    type

    =

    "submit"

    class

    =

    "btn btn-success"

    >

    Submit</

    button

    >
  47. </

    div

    >
  48. </

    form

    >
  49. </

    div

    >
  50. </

    div

    >
  51. </

    div

    >

  52. <div

    >
  53. </

    div

    >
  54. </

    form

    >
  55. </

    body

    >
  56. </

    html

    >

DEMO VIDEO

Video Link for this tutorial: https://youtu.be/ZaViGn2hiUE

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.


Download
You must upgrade your account or reply in the thread to view hidden text.
 

442,401

317,942

317,951

Top