从内容页面调用主页面jquery函数

时间:2015-06-01 17:38:40

标签: c# jquery asp.net vb.net

我在母版页上有一个Jquery函数,我试图在关注页面的按钮点击事件(来自代码后面)上调用但是收到错误信息

0x800a1391 - JavaScript运行时错误:'通知'未定义

到目前为止,我尝试了不同的东西,但没有运气。

如果我在内容aspx页面上放置以下标记,那么它会调用通知方法,但是在从后面的代码调用时它会如何工作。

function notification(type, title, message) {
        if (type == 'success') {
            Command: toastr["success"](message, title)
            //toastr.success(title,message);
        } else if (type == 'error') {
            toastr.error(message, 'Error');
        } else if (type == 'warning') {
            toastr.warning(message, 'Warning');
        } else {
            toastr.info(message, 'Information');
        }
    }

内容页面按钮控件位于updatePanel中。如果它导致任何问题,请不要这样做。

母版页jquery功能

Public Sub ShowNotification(sender As Object, e As EventArgs, ByVal type As NotificationType, ByVal title As String, ByVal message As String)
    Dim notifyType As String = ""
    Select Case type
        Case NotificationType.Success
            notifyType = "success"
        Case NotificationType.Erorr
            notifyType = "error"
        Case NotificationType.Info
            notifyType = "info"
        Case NotificationType.Warning
            notifyType = "warning"
    End Select

    ScriptManager.RegisterClientScriptBlock(TryCast(sender, Control), Me.GetType(), "Notify", "notification('" + notifyType + "' , '" + title + "','" + message + "');", True)
End Sub

功能背后的母版页代码

 TryCast(Me.Page.Master, amis).ShowNotification(sender, e, amis.NotificationType.Success, "email sent...", "")

隐含功能背后的网页代码

调用母版页功能。

Public Sub scheduler_2()
    RunWhen = Now + TimeValue("00:15:00")
    Application.OnTime RunWhen, "scheduler_1"
Application.ScreenUpdating = True
Do While Now < RunWhen
    Sheet5.Activate
    Call custom_wait(5)
    Sheet3.Activate
    Call custom_wait(5)
Loop

End Sub

0 个答案:

没有答案