Open (Show) BootStrap Modal Popup after registration success in ASP.Net using C# and VB.Net

on Feb 10, 2015 11:51 PM


I need to show a modal (Bootstrap Modal) after a user has successfully registered.

Here's my code.

<div runat="server" id="myModal" class="modal fade">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">Confirmation</h4>
            <div class="modal-body">
                <p>Do you want to save changes you made to document before closing?</p>
                <p class="text-warning"><small>If you don't save, your changes will be lost.</small></p>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                <button type="button" class="btn btn-primary">Save changes</button>

and the code behind.

myModal.Visible = true;

where is the problem?

Download FREE API for Word, Excel and PDF in ASP.Net: Download
on Feb 11, 2015 03:11 AM
on Feb 11, 2015 03:26 AM

Hi wozniak,

Please refer below sample code.


<html xmlns="">
<head id="Head1" runat="server">
    <meta charset="utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>Bootstrap 101 Template</title>
    <!-- Bootstrap -->
    <link href=""
        rel="stylesheet" />
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src=""></script>
      <script src=""></script>
    <script type="text/javascript">
        function ShowPopup() {
    <form id="form1" runat="server">
    <div class="container">
        <div class="row">
            <button type="button" style="display: none;" id="btnShowPopup" class="btn btn-primary btn-lg"
                data-toggle="modal" data-target="#myModal">
                Launch demo modal
            <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
            <script src=""></script>
            <!-- Include all compiled plugins (below), or include individual files as needed -->
            <script src=""></script>
            <div class="modal fade" id="myModal">
                <div class="modal-dialog">
                    <div class="modal-content">
                        <div class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                <span aria-hidden="true">&times;</span></button>
                            <h4 class="modal-title">
                                Registration done Successfully</h4>
                        <div class="modal-body">
                            <asp:Label ID="lblMessage" runat="server" />
                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">
                            <button type="button" class="btn btn-primary">
                                Save changes</button>
                    <!-- /.modal-content -->
                <!-- /.modal-dialog -->
            <!-- /.modal -->



protected void Page_Load(object sender, EventArgs e)
    ClientScript.RegisterStartupScript(this.GetType(), "alert", "ShowPopup();", true);
    this.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly";


Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
    ClientScript.RegisterStartupScript(Me.GetType(), "alert", "ShowPopup();", True)
    Me.lblMessage.Text = "Your Registration is done successfully. Our team will contact you shotly"
End Sub