Javascript 当asp.net页面具有特定查询字符串时调用JQuery函数
我有JQuery函数显示通知消息。 在我的asp.net页面中,我想在页面完全加载时调用它,例如:Request.QueryString[c_opID]!=无效的Javascript 当asp.net页面具有特定查询字符串时调用JQuery函数,javascript,c#,jquery,asp.net,Javascript,C#,Jquery,Asp.net,我有JQuery函数显示通知消息。 在我的asp.net页面中,我想在页面完全加载时调用它,例如:Request.QueryString[c_opID]!=无效的 我尝试使用ScriptManager.RegisterStartupScript()从Page_Load和Page_LoadComplete调用该函数,但该函数没有启动。另一方面,当我点击按钮时,它会做应该做的事情 JQuery函数: function showMessage(title, message) { PNotify
我尝试使用ScriptManager.RegisterStartupScript()从Page_Load和Page_LoadComplete调用该函数,但该函数没有启动。另一方面,当我点击按钮时,它会做应该做的事情 JQuery函数:
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代码隐藏调用:
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", @"showMessage('" + title + "','" + message + "');", true);
另一种选择是纯js 您只需使用javascript从url获取参数。这里有一个解决方案(从 ) 然后
$(function () {
if (getParameterByName('your_parameter_name')){
// show message
}
})
你能给我们看一下你用来在页面上加载这个脚本的代码吗?还有脚本itselfScriptManager.RegisterStartupScript(this,this.GetType(),“script”,@“PNotify.prototype.options.styleing=”“jqueryui”“;var notice=new PNotify({title:'Success!',text:'Computer have saved successfully',type:'Success',opacity:1,animate_speed:'fast',addclass:'custom});notice.get()。单击(函数(){notice.remove();});setTimeout(函数(){notice.remove();},3000);”,true);请在你的问题中添加代码标签,这不是一个可读性很好的解决方案,我试过了,效果很好!谢谢,这个解决方案中的问题是我有asp.net参数,我检查它们的值以显示不同的消息,例如,我检查当前线程的区域性以显示本地化消息。
$(function () {
if (getParameterByName('your_parameter_name')){
// show message
}
})