Scriptmanager not loading properly

436 views Asked by At

I want to show a div after an action. For now i will just use a button click event.

this is my jquery function:

function hideMessageBlock() {
        $('.alert').delay(5000).fadeOut('slow');
    }

i also tried this one:

$(document).ready(function(){
        console.log('READY to animate');
        function hideMessageBlock() {
            $('.alert').delay(5000).fadeOut('slow');
        }
    });

in my code behind i have the following code:

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);
        }

in the aspx i have declared a scriptmanager right after the scripts i use (bottom of the page before form and body closure):

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

The Error that i am receiving is : ReferenceError: hideMessageBlock is not defined The function is called before the whole jquery script is loaded (just guessing)

How can i resolve this issue?

1

There are 1 answers

0
kishen Biekhram On BEST ANSWER

I have already solved the issue. I had to move the function definition outside of the document.ready callback