在测试 Asp.Net Web 应用程序期间,我意识到 html 层(布局)支持 JQuery“淡入/出/切换/到”属性,但不支持像面板一样的 asp:层(布局)。
有关详细信息,您必须遵循我的以下代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Animated1._Default" %>
<!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>Untitled Page</title>
<style type="text/css">
#pnl1
{
width:100px;
height:150px;
background-color:red;
border-style:solid;
border-color:black;
border-width:3px;
}
</style>
<script src="jquery-1.9.1.js" type="text/jscript" ></script>
<script type="text/jscript">
$(document).ready(function(){
$("#<%=Btn.ClientID%>").click(function(){
$("#<%=pnl1.ClientID %>").fadeOut(3000);});
});
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Panel ID="pnl1" runat="server">
</asp:Panel>
<asp:Button ID="Btn" runat="server" Text="Mytext" />
</div>
</form>
</body>
</html>
现在按照上面的代码,像面板这样的 asp 控件不支持淡出属性。为什么?。
现在看一下带有 html 代码的相同示例,如下所示:只需使用上面的代码更改 Css ID 选择器和 Jquery。
这是 Css/Text 代码的样子:
#div1
{
width:100px;
height:150px;
background-color:red;
border-style:solid;
border-color:black;
border-width:3px;
}
//And Jquery Function:
<script src="jquery-1.9.1.js" type="text/jscript" ></script>
<script type="text/jscript">
$(document).ready(function(){
$("#Btn").click(function(){
$("#div1").fadeOut(3000);});
});
</script>
//Rest Of Body Code is here.
<body>
<form id="form1" runat="server">
<div>
<div id="div1"></div>
<input type="button" value="fade the div" id="Btn"/>
</div>
</form>
</body>
现在 div 支持淡出属性并且运行良好。
1.我的问题是为什么淡出在 html 上工作而不是在 asp:controls 上工作?
2.Jquery不支持asp:controls吗?
3.或者Css/JQuery和Asp:Controls之间有ID选择器的结论?
最后解决上述问题。如何在 Css 和 Jquery 之间处理 Asp Controls ID 的选择器,因为它可以完美运行。