相关疑难解决方法(0)

如何覆盖由Asp.Net UpdatePanel添加(动态)的Javascript函数?

我在只能想象是Javascript范围问题和Microsoft Asp.Net客户端框架方面遇到了一些麻烦。

由于此问题中所述的原因,我需要覆盖由Asp.Net的ScriptResource.axd提供并由其Validator服务器控件使用的javascript函数ValidatorConvert。

首先,我将介绍如何使代码正常工作。然后,我将展示一个无法正常工作的方案。

这是带有验证程序控件的简单Asp.Net WebForm:

<body>
<form id="form1" runat="server">
    <script type="text/javascript">
        function ValidatorConvert(op, dataType, val) {
            //>>Overwrite ValidatorConvert function.
            //>>Call to the original JS file will be below the form tag and above script tag
            return op.toString(); //<<Consider everything as valid (client side)
        }
    </script>
    <asp:ScriptManager runat="server"
        ID="Scriptmanager1" 
        allowcustomerrorsredirect="true" 
        asyncpostbackerrormessage="Operation cannot be executed."
        asyncpostbacktimeout="90"
        enablepartialrendering="true"
        enablescriptglobalization="true" 
        enablescriptlocalization="true" 
        supportspartialrendering="true" 
        scriptmode="Inherit"></asp:ScriptManager>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:CompareValidator
        ID="CompareValidator1"
        runat="server"
        ErrorMessage="Ops, not an integer"
        Operator="DataTypeCheck"
        Type="Integer"
        ControlToValidate="TextBox1"></asp:CompareValidator>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" …
Run Code Online (Sandbox Code Playgroud)

javascript asp.net

5
推荐指数
1
解决办法
1115
查看次数

标签 统计

asp.net ×1

javascript ×1