0

I was using the following script to call a javascript function only if my page in Edit Mode:

protected void Page_PreRender(object sender, EventArgs e)
{
    if (EditMode)
        ClientScript.RegisterStartupScript("".GetType(), 
                                           "EnableSelectableKey", 
                                           "EnableSelectableForRolesLists();",
                                            true);
}

After I added an update panel, the script has not been called.

How to fix the problem?

2 Answers 2

5

Using Sys.WebForms.PageRequestManager.endRequest as Dave_Stott says is a cleaner way to do this (if there is such a thing as "clean" when talking about UpdatePanels and client/server interaction). But you can also simply change your code to use ScriptManager instead of ClientScript and it should work:

ScriptManager.RegisterStartupScript("".GetType(), 
                                           "EnableSelectableKey", 
                                           "EnableSelectableForRolesLists();",
                                            true);
Sign up to request clarification or add additional context in comments.

Comments

1

Have a look at: http://msdn.microsoft.com/en-us/library/bb383810.aspx

This should point you in the right direction :)

2 Comments

I'm sorry, but that link has nothing to do with the question.
Pretty sure it does. See the answer by Jamie Treworgy which also references the exact same technique as a possible solution and provides an alternative. Answer is also accepted...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.