Jqmodal不在Updatepanel中工作

时间:2009-03-14 16:00:41

标签: asp.net jquery ajax updatepanel jqmodal

我有一个名为raise_alarm()的方法,它显示一个基于jquery的消息框。但是当我从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

1 个答案:

答案 0 :(得分: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知道如何处理部分回发。请快速查看this article on msdn