Hi I create a popup calendar and put the following code for clicking on calendar:
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
PopupControlExtender1.Commit(Calendar1.SelectedDate.ToShortDateString())
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "setCursor", "alert(777);", True)
End Sub
Page.ClientScript.RegisterClientScriptBlock will cause javascript executed auto when I clicking on popup calendar. It works for ATLAS. But after I moved it to AJAX, it doesn't work. no response for this javascrpt.
Help please.
With ASP.NET AJAX Beta, you need to move to ScriptManager.RegisterClientScriptBlock instead of Page.ClientScript.RegisterClientScriptBlock.Thanks. David.
But for my case, ScriptManager is put in master page. And the following code is put inside a user control (.ascx) and loaded dynamically.
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
PopupControlExtender1.Commit(Calendar1.SelectedDate.ToShortDateString())
Page.ClientScript.RegisterClientScriptBlock(Me.GetType(), "setCursor", "alert(777);", True)
End Sub
How to get ScriptManager object in user control?
I changed the code as:
Protected Sub Calendar1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs)
PopupControlExtender1.Commit(Calendar1.SelectedDate.ToShortDateString())
Dim sm As Microsoft.Web.UI.ScriptManager
sm = Page.Master.FindControl("MasterScriptManager")
sm.RegisterClientScriptBlock(Me.Page, Me.GetType(), "setFocus", "alert(777);", True)
End Sub
it still doesn't work. Help please.
The Control parameter to RegisterClientScriptBlock (the first param) needs to specify a control that's inside the UpdatePanel that's being updated when the script block is to be updated. I suspect that Me.Page in your example does not satisfy that requirement, so please try a control that does.
Thank you so much, David.
No comments:
Post a Comment