Hi Kevinf,
Use dialogClass to set the css style.
Please check this example. Now please take its reference and correct your code as per your requirement.
HTML
<style type="text/css">
.ui-dialog.success-dialog .ui-dialog-titlebar {
color: yellow !important;
font-weight: bold !important;
}
.ui-dialog.error-dialog .ui-dialog-titlebar {
color: aqua !important;
font-weight: bold !important;
}
</style>
Age:
<asp:TextBox runat="server" ID="txtAge" />
<asp:Button Text="Dialog" ID="btnDialog" runat="server" OnClick="bDelete_Click" />
<asp:Button Text="Yes" ID="btnYes" runat="server" OnClick="OnYes" Style="display: none;" />
<asp:Button Text="No" ID="btnNo" runat="server" OnClick="OnNo" Style="display: none;" />
<asp:Button Text="Cancel" ID="btnCancel" runat="server" OnClick="OnCancel" Style="display: none;" />
<asp:HiddenField ID="hfYesMessage" runat="server" />
<div id="dialog"></div>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/jquery-ui.js"></script>
<link rel="stylesheet" type="text/css" href="https://ajax.aspnetcdn.com/ajax/jquery.ui/1.8.9/themes/blitzer/jquery-ui.css" />
<script type="text/javascript">
function ShowPopup(message, title, cssclass) {
$("#dialog").html(message);
$("#dialog").dialog({
title: title,
modal: true,
dialogClass: cssclass,
buttons: {
Yes: function () {
$(this).dialog('close');
$('[id*=btnYes]').trigger('click');
},
No: function () {
$(this).dialog('close');
$('[id*=btnNo]').trigger('click');
},
Cancel: function () {
$(this).dialog('close');
$('[id*=btnCancel]').trigger('click');
}
}
});
};
</script>
Code
C#
protected void bDelete_Click(object sender, EventArgs e)
{
string message = "Do You Wish to Delete";
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + message + "','Information','success-dialog');", true);
}
protected void OnYes(object sender, EventArgs e)
{
int age = int.Parse(txtAge.Text);
if (age < 21 && string.IsNullOrEmpty(hfYesMessage.Value))
{
string message = "Age Is Under 21 Continue Yes or No to correct Age or Cancel to Exit";
hfYesMessage.Value = message;
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "ShowPopup('" + message + "','Confirmation','error-dialog');", true);
}
else
{
hfYesMessage.Value = string.Empty;
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('Record deleted.');", true);
}
}
protected void OnNo(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('You clicked No.');", true);
}
protected void OnCancel(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(this.GetType(), "Popup", "alert('You clicked Cancel.');", true);
}
VB.Net
Protected Sub bDelete_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim message As String = "Do You Wish to Delete"
ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "ShowPopup('" & message & "','Information','success-dialog');", True)
End Sub
Protected Sub OnYes(ByVal sender As Object, ByVal e As EventArgs)
Dim age As Integer = Integer.Parse(txtAge.Text)
If age < 21 AndAlso String.IsNullOrEmpty(hfYesMessage.Value) Then
Dim message As String = "Age Is Under 21 Continue Yes or No to correct Age or Cancel to Exit"
hfYesMessage.Value = message
ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "ShowPopup('" & message & "','Confirmation','error-dialog');", True)
Else
hfYesMessage.Value = String.Empty
ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "alert('Record deleted.');", True)
End If
End Sub
Protected Sub OnNo(ByVal sender As Object, ByVal e As EventArgs)
ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "alert('You clicked No.');", True)
End Sub
Protected Sub OnCancel(ByVal sender As Object, ByVal e As EventArgs)
ClientScript.RegisterStartupScript(Me.GetType(), "Popup", "alert('You clicked Cancel.');", True)
End Sub
Screenshot