Reputation: 688
I have JQuery function shows notification message. From my asp.net page I want to call it when page gets fully loaded e.g when: Request.QueryString[c_opID] != null; I tried to call the function from Page_Load and Page_LoadComplete using ScriptManager.RegisterStartupScript() but the function doesn't fire up. On other hand, when I call it on button click it does what should be done.
JQuery Function:
function showMessage(title, message) {
PNotify.prototype.options.styling = "jqueryui";
var notice = new PNotify({
title: title,
text: message,
type: 'success',
opacity: 1,
animate_speed: 'fast',
addclass: 'custom'
});
notice.get().click(function() {
notice.remove();
});
setTimeout(function() {
notice.remove();
}, 3000);
}
Asp.Net code behind call:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", @"showMessage('" + title + "','" + message + "');", true);
Upvotes: 0
Views: 446
Reputation: 4914
Alternative would be pure js
All you need is to get parameter from url with javascript. here is one solution (copied from How can I get query string values in JavaScript? )
function getParameterByName(name) {
name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
results = regex.exec(location.search);
return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}
And then
$(function () {
if (getParameterByName('your_parameter_name')){
// show message
}
})
Upvotes: 2