Adding Javascript on Initial Load after updating UpdatePanels
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
精彩评论