我在我的vb.net項目中的以下子例程運行良好,但我不斷地得到建立警告:如何解決的RegisterClientScriptBlock是在Visual Studio過時警告
「公衆可重寫小組的RegisterClientScriptBlock(鍵字符串,腳本 As String)'已過時:'推薦的替代方法是 ClientScript.RegisterClientScriptBlock(Type type,string key,string script)。訪問http://go.microsoft.com/fwlink/?linkid=14202
我認爲這將是最好的,如果我使用正確的方法。我按照這裏的說明 - http://msdn.microsoft.com/en-us/library/system.web.ui.page.registerclientscriptblock.aspx,但它沒有很大的意義。任何幫助,將不勝感激。
Protected Sub DBC_MEMBER_IsActive_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DBC_MEMBER_IsActive.CheckedChanged
Dim showmessage As String = "Warning!\r\n \r\n Unticking this box will delete this Member from the Databse. \r\n \r\n If you are unsure, make sure the box remains ticked"
Dim alertScript As String = "<script language=JavaScript> "
alertScript += "alert('" & showmessage & "');"
alertScript += "</script" & "> "
If Not ClientScript.IsClientScriptBlockRegistered("alert") Then
Me.RegisterClientScriptBlock("alert", alertScript)
End If
End Sub
我設法讓你的更新工作,但我不得不使用以下:如果不是ClientScript.IsClientScriptBlockRegistered(GetType(會員),「alert」)然後 ClientScript.RegisterClientScriptBlock(GetType(Member),「alert」,alertScript) End If – James 2011-01-29 21:45:36