Hi @Gani_tpt,
Scriptmanager alert not displaying properly in same page
I do not quite understand you. Don't you want to achieve something similar to Scriptmanager alerts?
I offer two methods that may help you.
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('Record Inserted Successfully')", true);
Or you can try using Bootstrap modal popups.
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link rel="stylesheet" href='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/css/bootstrap.min.css' media="screen" />
<script type="text/javascript" src='https://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.3.min.js'></script>
<script type="text/javascript" src='https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.0.3/js/bootstrap.min.js'></script>
<script type="text/javascript">
function ShowPopup(title, body) {
$("#MyPopup .modal-title").html(title);
$("#MyPopup .modal-body").html(body);
$("#MyPopup").modal("show");
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:Button ID="btnShowPopup" runat="server" Text="Show Popup" OnClick="ShowPopup"
CssClass="btn btn-info btn-lg" />
<!-- Modal Popup -->
<div id="MyPopup" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title"></h4>
<button type="button" class="close" data-dismiss="modal">
×</button>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-danger" data-dismiss="modal">
Close</button>
</div>
</div>
</div>
</div>
<!-- Modal Popup -->
</form>
</body>
</html>
protected void ShowPopup(object sender, EventArgs e)
{
string title = "Greetings";
string body = "Data inserted successfully!!!";
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + title + "', '" + body + "');", true);
}
Or you can simply use a Label control to display the information.
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
<asp:Label ID="Label1" runat="server" ForeColor="Red"></asp:Label>
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Record Inserted Successfully";
}
Best regards,
Lan Huang
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.