Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Scriptmanager未正确加载_C#_Jquery_Asp.net_Timeout_Scriptmanager - Fatal编程技术网

C# Scriptmanager未正确加载

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() {

我想在一个动作后显示一个div。 现在我只使用一个按钮点击事件

这是我的jquery函数:

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>