Hi paulrajmca,
I have checked. Your code is working.
Refer below code.
HTML
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
<script type="text/javascript" src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>
<asp:Button ID="btnShow" Text="Show" runat="server" OnClick="OnShow" />
Code
C#
protected void OnShow(object sender, EventArgs e)
{
ErrorMessage(this, "Welcome", "Greeting");
}
public void ErrorMessage(UI.Control Control, string Message, string Title = "Alert", string callback = "")
{
try
{
ScriptManager.RegisterStartupScript(Control, Control.GetType, "Script", "swal('" + Title + "','" + Message + "','error');", true);
}
catch (Exception ex)
{
}
}
VB.Net
Protected Sub OnShow(sender As Object, e As EventArgs)
ErrorMessage(Me, "Welcome", "Greeting")
End Sub
Public Sub ErrorMessage(ByVal Control As UI.Control, ByVal Message As String, Optional ByVal Title As String = "Alert", Optional ByVal callback As String = "")
Try
ScriptManager.RegisterStartupScript(Control, Control.GetType, "Script", "swal('" + Title + "','" + Message + "','error');", True)
Catch ex As Exception
End Try
End Sub
Screenshot