开发者

Adding Javascript on Initial Load after updating UpdatePanels

开发者 https://www.devze.com 2023-02-19 03:40 出处:网络
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.

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 al开发者_开发问答ert 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?


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

0

精彩评论

暂无评论...
验证码 换一张
取 消