0

我在 DotNetNuke 框架中有一个使用 ascx 控件,它允许用户在文本框中输入电话号码。它需要输入掩码 (999) 999-9999 和一个复选框,用于切换输入掩码关闭/打开以允许输入国际号码。我在测试 Chrome 时遇到了 asp.net ajax 控制工具包的几个问题,所以我决定尝试使用 jquery.maskedinput-1.3.min.js 扩展名的 jQuery,即使我是新手,我通过添加应用了掩码以下脚本部分中的代码,但复选框但只能工作一次。我认为这是因为文本框位于更新面板中。该复选框已启用自动回发,但我不知道如何捕获该事件以强制重新加载 javascript。

    jQuery(document).ready(function () {
        jQuery(".primarymask").mask("(999) 999-9999");

        jQuery("input[name=ckbIntPrimaryPhone]").click(function () {
            if (jQuery(this).is(":checked")) {
                jQuery(".primarymask").mask("");
            }
            else {
                jQuery(".primarymask").mask("(999) 9999-9999");
            }
        }); 
    });

我尝试使用下面的代码,然后重复 js 函数,但面具只会消失,直到点击然后一直回来。

    var prm = Sys.WebForms.PageRequestManager.getInstance();
    prm.add_endRequest(function () {

\ }

4

2 回答 2

1

你可以试试这个:

将此代码放入您的 ascx/aspx 代码文件

<asp:ScriptManager ID="ScriptManager1" EnablePartialRendering="true" syncPostBackTimeout="70" runat="server" />

<script language="javascript" type="text/javascript">
    Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(update_start);
    Sys.WebForms.PageRequestManager.getInstance().add_endRequest(update_end);
    function update_start(sender, args) {
        // code here executes when update panel begins to update
    }

    function update_end(sender, args) {
        // code here executes when update panel is done updatinging
    }
</script>
于 2012-04-17T22:48:06.343 回答
0

使用 __dopostback('updatePanelId') MSAjax 刷新更新面板

于 2012-04-17T22:43:27.057 回答