I am creating a Web Application from scratch in which I am using Bootstrap.
I am new in Bootstrap. This is the first time I am using it.
I want to show bootstrap Modal pop up, on click of "Save" Button,
i.e., When I click on save button, the insert query execute, and after data gets inserted into the database, a bootstrap modal pop shall appear with Text Information as "Records Saved successfully"
Below is the code I am using to achieve my requirement.
C# Code:
protected void btnSave_Click(object sender, EventArgs e)
{
SqlConnectionClass saveData = new SqlConnectionClass();
saveData.commandExec("INSERT INTO [Block](Code, Description, EntityStatus, CreatedAt)"
+ "VALUES('" + txtCode.Text.Trim() + "','" + txtDesc.Text.Trim() + "','" + txtEntityStatus.Text.Trim() + "','" + DateTime.Now.ToShortTimeString() + "' )");
//ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "none","<script>$('#myModal').modal('show');</script>", false);
}
HTML:
<div class="row" style="margin-top:20px;">
<div class="col-lg-12">
<div class="col-lg-6" style="margin-bottom:20px;">
<asp:Button ID="btnSave" runat="server" Text="Save Template" class="btn save" OnClick="btnSave_Click" data-toggle="modal" data-target="#myModal"/>
<asp:Button ID="btnCancel" runat="server" Text="Cancel" class="btn btn-default" OnClick="btnCancel_Click"/>
</div>
</div>
</div>
<%--Modal Pop up--%>
<div class="row">
<div class="col-lg-12">
<%--<button type="button" class="btn btn-info btn-lg" data-toggle="modal" data-target="#myModal">Open Modal</button>--%>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Information</h4>
</div>
<div class="modal-body">
<p>Records Saved Successfully.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
</div>
NOTE:
Please let me know how to control the Text Information inside modal pop up based on my Query.
For instance:
1. If I am Inserting records in Database, then the msg shall display as "Records saved successfully"
inside Modal Text.
2. If I am Deleting records from Database, then the msg shall display as "Records deleted successfully"
inside Modal Text.
3. If I am Updating records from Database, then the msg shall display as "Records updated successfully"
inside Modal Text.
Please help me how to achieve it.
Thanks in advance.