Reputation: 7451
I have javascript that working in form but when I tried to put it on content is not working anymore..
Here's working javascript:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Numeric.aspx.cs" Inherits="Numeric" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.numeric.js"></script>
</head>
<body>
<form id="form1" runat="server">
<div>
<form>
Numbers only:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input class="numeric" type="text" />
<script type="text/javascript">
$("#TextBox1").numeric();
</script>
</form>
</div>
</form>
</body>
</html>
and here's not working javascript in content:
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true" CodeFile="NumericNew.aspx.cs" Inherits="NumericNew" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript" src="Scripts/jquery.numeric.js"></script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<asp:ScriptManager ID="ScriptManager1" runat="server" > </asp:ScriptManager>
<div>
Numbers only:
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<input class="numeric" type="text" />
<script type="text/javascript">
$("#TextBox1").numeric();
</script>
</div>
</asp:Content>
Please let me know thoughts.. Thank you.
Upvotes: 0
Views: 1478
Reputation: 2035
Because you are using a master page the control id not remain TextBox1
Use $("#<%= TextBox1.ClientID %>")
If you check in firebug or another tool you will realize that the id is like ctl00_TextBox1
Upvotes: 3