验证插件在更新面板中不起作用 [英] Validation plugin is not working in update panel

查看:59
本文介绍了验证插件在更新面板中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个更新面板,面板内部有文本框和按钮.现在,我使用的是jQuery Validation插件,但是在更新面板中使用时,该验证插件无法正常工作.

I have an update panel and inside the panel text boxes and buttons are available. Now I am using the jQuery Validation plugin, but the validation plugin is not working when it is used in the update panel.

例如:

function GetAddressTargetList() {
    var objArray = new Array();
    var objAddressElement = new Object();

    objAddressElement = new Object();
    objAddressElement.Id = "ddlAccType"; 
    objAddressElement.Rules = "required";
    objAddressElement.TargetControlType = "select";
    objArray[objArray.length] = objAddressElement;
    objAddressElement = new Object();
}

和页面级别(.aspx)

and in the page level (.aspx)

$(document).ready(function () {
    GetAddressTargetList();
});

function pageLoad(sender, args) {
    // To load the tooltip in update panel
    if (args.get_isPartialLoad()) {
        GetAddressTargetList();
    }
}

使用更新面板时如何获得验证?

How can I get the validation when I am using the update panel working?

推荐答案

我认为您忘记了初始化pageLoad

I think that you have forget to initilize the pageLoad

将此添加到您的代码中:

Add this on your code:

$(document).ready(function () {
    Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoaded);
});

function PageLoaded(sender, args) {
    GetAddressTargetList();
}

参考: http://msdn.microsoft.com /en-us/library/bb397523(VS.100).aspx

我已将 pageLoad更新为PageLoaded ,以避免在 rs 发表评论后发生冲突.我认为UpdatePanel有一种自定义的方式来处理事件,而我们试图在UpdatePanel更新内容后在javascript上触发事件.

I have update the pageLoad to PageLoaded, to avoid conflict after the comment of the rs. In my opinion the UpdatePanel have a custom way to handle the events and what we try here is to trigger the event on javascript after the UpdatePanel Updates the content.

这篇关于验证插件在更新面板中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆