C# Scriptmanager未正确加载
我想在一个动作后显示一个div。 现在我只使用一个按钮点击事件 这是我的jquery函数:C# Scriptmanager未正确加载,c#,jquery,asp.net,timeout,scriptmanager,C#,Jquery,Asp.net,Timeout,Scriptmanager,我想在一个动作后显示一个div。 现在我只使用一个按钮点击事件 这是我的jquery函数: function hideMessageBlock() { $('.alert').delay(5000).fadeOut('slow'); } 我也试过这个: $(document).ready(function(){ console.log('READY to animate'); function hideMessageBlock() {
function hideMessageBlock() {
$('.alert').delay(5000).fadeOut('slow');
}
我也试过这个:
$(document).ready(function(){
console.log('READY to animate');
function hideMessageBlock() {
$('.alert').delay(5000).fadeOut('slow');
}
});
在我的代码隐藏中,我有以下代码:
protected void Button1_Click(object sender, EventArgs e)
{
alertSuccessBlock.Visible = true;
lbl_alertSuccessBlock.Text = "Animate this block with timeout!";
ScriptManager.RegisterStartupScript(this, this.GetType(), "ScriptManager1", "hideMessageBlock();", true);
}
在aspx中,我在使用的脚本之后声明了一个scriptmanager(表单和正文关闭之前的页面底部):
我收到的错误是:ReferenceError:hideMessageBlock未定义
在加载整个jquery脚本之前调用该函数(只是猜测)
如何解决这个问题?我已经解决了这个问题。我不得不将函数定义移到文档之外。ready callback我已经解决了这个问题。我必须将函数定义移到document.ready回调($(function(){})之外:如果在另一个函数内声明一个函数,那么它的作用域仅在该外部函数内。
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>