Jquery电话掩码在MVC中不工作
我有一个网络表单页面呼叫newcall.aspx,其中有一个文本框电话号码。电话号码被屏蔽了(999)999-9999它在普通的网络表单中工作得非常好 但是我们把它改成了MVC。我们有一个Sitemaster,并将其放入newcall.aspx。我的脚本运行得很好,但在MVC中不起作用。有人能告诉我我缺少了什么吗 MVC代码(newcall.aspx)Jquery电话掩码在MVC中不工作,jquery,asp.net,asp.net-mvc,Jquery,Asp.net,Asp.net Mvc,我有一个网络表单页面呼叫newcall.aspx,其中有一个文本框电话号码。电话号码被屏蔽了(999)999-9999它在普通的网络表单中工作得非常好 但是我们把它改成了MVC。我们有一个Sitemaster,并将其放入newcall.aspx。我的脚本运行得很好,但在MVC中不起作用。有人能告诉我我缺少了什么吗 MVC代码(newcall.aspx) 主要电话号码: 电话号码: $('Tb#u主电话')。掩码('999)999-9999'); $('Tb'第二部电话')。掩码('999)99
主要电话号码:
电话号码:
$('Tb#u主电话')。掩码('999)999-9999');
$('Tb'第二部电话')。掩码('999)999-9999');
呈现输入的HTML是什么?请将此添加到您的问题中。在没有看到更多标记的情况下,我只是猜测,但很可能在页面顶部有此标记,因此当脚本尝试应用掩码时,输入尚未呈现。另一个问题可能是,根据您使用的“渲染模式”,输入的ID不匹配(使用母版页会更改服务器控件的生成名称和ID)。使用浏览器的开发人员控制台(通常通过按F12键激活)并检查生成的标记。我假设您将看到除Tb\u Main\u Phone等以外的其他内容作为输入的ID。问题已解决。感谢Tieson T。你说得对。由于以下原因,Tb\u主手机自动重新分配给MainContent\u Tb\u主手机。因此,将“#Tb_Main_Phone”改为“#Main content_Tb_Main_Phone”解决了这个问题。非常感谢。
<%@ Page Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="NewCall.aspx.cs" Inherits="HITAssist.NewCall" ValidateRequest="false" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %>
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<span class="Label">Phone Number Main:</span>
<asp:TextBox ID="Tb_Main_Phone" runat="server" Width="250"></asp:TextBox>
<span class="Label">Phone Number Secondary:</span>
<asp:TextBox ID="Tb_Second_Phone" runat="server" Width="250"></asp:TextBox>
<script type="text/javascript" src="Js/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="Js/jquery.maskedinput-1.4.1.min.js"> </script>
<script type="text/javascript">
$('#Tb_Main_Phone').mask('(999) 999-9999');
$('#Tb_Second_Phone').mask('(999) 999-9999');
</script>
</asp:Content>