I want to perform as an alert but with jQuery, that is, if something bad appears that shows the alert as a popup
.
That is to say at this moment it does the validation but with a alert
of JavaScript I want it to be more friendly for that I'm doing with jQuery.
This is my current code.
<script type="text/javascript">
function ShowPopup(message) {
$(function () {
$("#dialog").html(message);
$("#dialog").dialog({
title: "jQuery Dialog Popup",
buttons: {
Close: function () {
$(this).dialog('close');
}
},
modal: true
});
});
};
</script>
asp:ScriptManager ID="ScriptManager1" runat="server"> /asp:ScriptManager> asp:UpdatePanel ID="UpdatePanel1" runat="server"> ContentTemplate> div id="dialog" style="display: none"> /div> asp:TextBox ID="txtnumero" runat="server"> asp:RegularExpressionValidator ID="RegexDecimal" runat="server" ValidationExpression="((\d+)((\.\d{1,2})?))$" ErrorMessage="Ingrese un monto decimal" ControlToValidate="txtnumero" /> asp:ValidationSummary runat="server" ShowMessageBox="true" ShowSummary="false" /> asp:Button ID="btnShowPopup" runat="server" Text="Guardar" OnClick="btnShowPopup_Click" /> /ContentTemplate> /asp:UpdatePanel> /form>
In the code behind :
using (SqlConnection conn = new SqlConnection("Data Source=PIEROFLORES-PC;Password=123456789;Initial Catalog=colegio;Integrated Security=True"))
{
string sql = @"Insert into numero (numero)
values(@numero)";
conn.Open();
SqlCommand cmd = new SqlCommand(sql, conn);
cmd.Parameters.AddWithValue("@numero", txtnumero.Text);
string message = "Message from server side";
cmd.ExecuteNonQuery();
ScriptManager.RegisterStartupScript((sender as Control), this.GetType(), "Popup", "ShowPopup('" + message + "');", true);
}
As an example: