1

On my Page_Load command for a page, I have a couple of tests that are performed before the screen is displayed with an alert box displaying if the user cannot access the screen.

     If Not Page.IsPostBack Then

   UpdatePanel1.ContentTemplateContainer.Controls.Add(ctl)
   UpdatePanel1.Update

   UpdatePanel2.ContentTemplateContainer.Controls.Add(ctl)
   UpdatePanel2.Update

    If ScreenAccessible = False

   ScriptManager.RegisterStartupScript(Me, Me.GetType(), "denied", "alert('Access Denied');", True)
    End If : End If

I would assume that based on the order of the procedure above, the update panels should update first, and then the alert message will follow.

However, the alert message shows up first, with the update panels empty. When I click the OK button on the alert box, the update panels are correctly render.

How do I allow the JavaScript alert box to appears after the update panels have rendered?

1 Answer 1

1

Did you try:

If ScreenAccessible = False

    ScriptManager.RegisterStartupScript(Me, Me.GetType(), "denied", _
        "setTimeout(function(){alert('Access Denied');},300);" , True)

End If

Reference:
http://www.w3schools.com/jsref/met_win_settimeout.asp

Sign up to request clarification or add additional context in comments.

Comments

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.