User-893317190 posted
Hi mariolopes,
Not clear about how Pnotify realizes the message pop up,but when you write response.write , the pnotify script will be moved into body element instead of the head.
You could open F12 to check.
So , if you want your code to work without Response.Write , you could move your pnotify into body instead of head.
<head runat="server">
<title></title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js" ></script>
<link href="pnotify.custom.min.css" rel="stylesheet" />
</head>
<body>
<script src="pnotify.custom.min.js"></script>
<script>
function showMessage(title, msg)
{
debugger;
new PNotify({
title: title,
text: msg,
type: 'success',
delay: 500
});
}
</script>
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click"/>
</form>
There is another way I have tried.That is to use window.onload or $(function())
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", @"
$(function(){
showMessage('title','msg')
})
", true);
}
Best regards,
Ackerly Xu