0

jqueryに基づくメッセージボックスを表示するraise_alarm()という名前のメソッドがあります。しかし、Updatepanel内にあるコントロール(送信ボタンなど)のイベントからこのメソッドを呼び出すと、機能しません。関連するコードは以下のとおりです。どうすれば修正できますか?

 Public Sub Raise_Alarm(ByVal p_Page As Page, ByVal p_Message As String, Optional ByVal p_IsError As Boolean = True)
        Dim strScript As String
        strScript = "$(function() { Mesaj('" & p_Message & "'); });" & ControlChars.NewLine
        p_Page.ClientScript.RegisterStartupScript(p_Page.GetType(), "alert", strScript, True)
end sub

Private Sub dtlQuestion_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtlQuestion.ItemCommand
        If Not User.Identity.IsAuthenticated Then
            Raise_Alarm(Me, "Giriş Yapmadan Oy Veremezsiniz")
            Exit Sub
        End If
end sub
4

1 に答える 1

1

ScriptManagerの代わりに使用する必要がありp_Page.ClientScriptます。

編集:例。私はあなたのコードで置き換えp_Page.ClientScriptました。ScriptManager

Public Sub Raise_Alarm(ByVal p_Page As Page, ByVal p_Message As String, Optional ByVal p_IsError As Boolean = True)
        Dim strScript As String
        strScript = "$(function() { Mesaj('" & p_Message & "'); });" & ControlChars.NewLine
        ScriptManager.RegisterStartupScript(p_Page.GetType(), "alert", strScript, True)
end sub

Private Sub dtlQuestion_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dtlQuestion.ItemCommand
        If Not User.Identity.IsAuthenticated Then
            Raise_Alarm(Me, "Giriş Yapmadan Oy Veremezsiniz")
            Exit Sub
        End If
end sub

ClientScriptはajax対応ではなく、ScriptManagerは部分的なポストバックを処理する方法を知っています。msdnに関するこの記事をざっと見てください。

于 2009-03-14T16:13:18.050 に答える