0
在我的ASP.NET頁面上,我有一個按鈕。點擊服務器端後,應該生成一個代表jQuery對話框和相關JavaScript塊內容的div。但是按鈕點擊後,頁面和JavaScript都不包含在頁面中。在點擊時註冊控件和腳本還是太晚了,或者爲什麼不起作用?ASP.NET:按鈕單擊後顯示jQuery對話框
'create JavaScript block
Dim strClientScript As String = String.Empty
Dim strMessageControlId As String = "jQueryDialog" & Me.MyContainer.Controls.Count
strClientScript &= "$(function(){" & NewLine
strClientScript &= " $(""#" & strMessageControlId & """).dialog({" & NewLine
strClientScript &= " bgiframe:true, " & NewLine
strClientScript &= " autoOpen:true, " & NewLine
strClientScript &= " modal:true, " & NewLine
strClientScript &= " closeOnEscape:false, " & NewLine
strClientScript &= " width:600, " & NewLine
strClientScript &= " height:450 " & NewLine
strClientScript &= " });" & NewLine
strClientScript &= "});"
'create div for the jQuery Dialog
Dim strHtml As String = String.Empty
strHtml &= "<div id=""" & strMessageControlId & """ title=""My title"">" & NewLine
strHtml &= strMessage & NewLine
strHtml &= "</div>"
'add the HTML to the page
Me.MyContainer.Controls.Add(New LiteralControl(strHtml))
'register the Javascript
Me.Page.ClientScript.RegisterClientScriptBlock(Me.GetType, "Key." & strMessageControlId, strClientScript, True)