C# 网页上的Jquery出现错误
在我的网页中,我有两个绑定到jquery的控件。 一个是用于将文本框值复制到剪贴板的按钮,另一个是用于输入日期的文本框 但问题是,当我调试这个web应用程序时,它抛出jquery错误。 当我注释掉一个javascript方法并进行调试时,它可以正常工作(两个javascript方法都尝试过) 但是当我不发表评论时,它就不起作用了 Aspx代码:C# 网页上的Jquery出现错误,c#,javascript,jquery,asp.net,web-applications,C#,Javascript,Jquery,Asp.net,Web Applications,在我的网页中,我有两个绑定到jquery的控件。 一个是用于将文本框值复制到剪贴板的按钮,另一个是用于输入日期的文本框 但问题是,当我调试这个web应用程序时,它抛出jquery错误。 当我注释掉一个javascript方法并进行调试时,它可以正常工作(两个javascript方法都尝试过) 但是当我不发表评论时,它就不起作用了 Aspx代码: <%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEven
<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="searchSerialResult.aspx.cs" Inherits="Locker.searchSerialResult" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
<style type="text/css">
.auto-style3 {
color: #CC3300;
font-size: x-large;
}
.auto-style1 {
color: #FFFFFF;
font-size: large;
}
.auto-style2 {
color: #000000;
}
</style>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MainContent" runat="server">
<p>
<p>
<p>
<strong> <span class="auto-style3"> Recorded Information</span><span class="auto-style1"> </span></strong>
<div style="width:70%; margin: auto auto; text-align:left; ">
<asp:Panel ID="Panel1" runat="server" BorderStyle="None">
<asp:Label ID="Label4" runat="server" CssClass="auto-style2" style="font-weight: 700; font-size: large" Text="Details for :"></asp:Label>
<asp:Label ID="Label5" runat="server" style="font-weight: 700; font-size: large; color: #0000FF"></asp:Label>
<br />
<br />
<asp:Label ID="Label1" runat="server" CssClass="auto-style2" Font-Bold="False" style="font-weight: 700; font-size: large" Text="Serial :"></asp:Label>
<asp:TextBox ID="TextBox2" runat="server" BorderStyle="Solid" Enabled="False" Font-Size="Medium" ForeColor="Black" Width="213px"></asp:TextBox>
<asp:Button ID="Button3" runat="server" Text="Copy Me!"/>
<script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="Scripts/jquery.zclip.js" type="text/javascript"></script>
<script src="Scripts/jquery.zclip.min.js" type="text/javascript"></script>
<script>
$(document).ready(function () {
$('#<%=Button3.ClientID%>').zclip({
path: 'ZeroClipboard.swf',
copy: function () { return $('#<%=TextBox2.ClientID%>').val(); }
});
});
</script>
<br />
<br />
<asp:Label ID="Label13" runat="server" CssClass="auto-style2" Font-Bold="False" style="font-weight: 700; font-size: large" Text="Serial Type :"></asp:Label>
<asp:DropDownList ID="DropDownList1" runat="server" Height="26px" Width="181px" AutoPostBack="True" Enabled="False" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Never Expire</asp:ListItem>
<asp:ListItem>Expire</asp:ListItem>
</asp:DropDownList>
<asp:Label ID="Label14" runat="server" CssClass="auto-style2" Font-Bold="False" style="font-weight: 700; font-size: large" Text="Expiry Date :" Visible="False"></asp:Label>
<asp:TextBox ID="TextBox6" runat="server" BorderStyle="Solid" Enabled="False" Height="16px" Visible="False" Width="136px"></asp:TextBox>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
<link rel="stylesheet" href="/resources/demos/style.css" />
<script>
$(function () {
$("#<%=TextBox6.ClientID%>").datepicker({
});
});
</script> <br />
<br />
<asp:Label ID="Label6" runat="server" style="font-weight: 700; font-size: large" Text="Description :" CssClass="auto-style2"></asp:Label>
<asp:TextBox ID="TextBox5" runat="server" BorderStyle="Solid" Font-Size="Medium" Height="48px" TextMode="MultiLine" Width="217px" Enabled="False"></asp:TextBox>
<br />
<br />
<asp:Label ID="Label7" runat="server" style="font-weight: 700; font-size: small" Text="Last Editor was " CssClass="auto-style2"></asp:Label>
<asp:Label ID="Label8" runat="server" style="font-weight: 700; font-size: small" CssClass="auto-style2"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Edit" Width="97px" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Update" Visible="False" Width="97px" />
<br />
<br />
<asp:Label ID="Label12" runat="server" style="font-weight: 700; font-size: large; color: #0000FF" Visible="False"></asp:Label>
<br />
<br />
</asp:Panel>
</div>
</asp:Content
.自动样式3{
颜色:#CC3300;
字号:x大号;
}
.auto-style1{
颜色:#FFFFFF;
字体大小:大号;
}
.auto-style2{
颜色:#000000;
}
记录的信息
$(文档).ready(函数(){
$('#').zclip({
路径:“ZeroClipboard.swf”,
复制:函数(){return$('#').val()}
});
});
永不过期
到期
$(函数(){
$(“#”)日期选择器({
});
});
您包含了多个版本的jQuery,第二个版本覆盖了第一个版本
因此,与第一个版本相关的任何插件都将被删除。(本例中为ZClip)没错。您不能两次使用同一jquery插件库(zclip)将其附加到$sign。如果您真的同时需要(源代码和缩微代码),那么应该为其中一个使用不同的变量名。否则会引起冲突
因此,我希望您使用以下代码:
<script src="Scripts/jquery-1.9.1.js" type="text/javascript"></script>
<script src="Scripts/jquery.zclip.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function () {
$('#<%=Button3.ClientID%>').zclip({
path: 'ZeroClipboard.swf',
copy: function () { return $('#<%=TextBox2.ClientID%>').val(); }
});
});
</script>
$(文档).ready(函数(){
$('#').zclip({
路径:“ZeroClipboard.swf”,
复制:函数(){return$('#').val()}
});
});
如果您使用的是生产环境。如果您使用的是开发环境,那么您应该使用jQuery插件的未压缩版本文件。旁注:有很多比使用
更好的方法来对齐页面上的元素。那太懒了。:/您应该学习CSS或与了解CSS的人合作。然后您应该检查zclip插件是否与您的jquery版本兼容。如果您只包含了这两个js库,那么它应该可以工作。即使使用两个jquery,它也可以正常工作,但如果您查看我的代码,就会发现另一个控件也使用jquery。如果我注释掉该jquery,则抛出异常。。