我想创建一个类似于本网站上的常见问题解答页面
http://www.microsoft.com/windows/windows-7/faq.aspx
当您点击问题时,答案会展开。再次单击它,它会折叠。
我的问题、答案存储在数据库中。我用谷歌搜索并发现有这个 JavaScript 代码来实现这个,但也遇到了一些说可以使用 Repeater Controls 完成的东西。
该怎么做?任何指向某些教程的链接都会很棒。
最佳答案
您可以使用 jQuery 来完成。假设您有一个页面名称 Faq.aspx
。
因此,将此代码放入您的 .aspx 页面。
<head>
<script src="js/jquery_div.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
//hide the all of the element with class msg_body
$(".msg_body").hide();
//toggle the componenet with class msg_body
$(".msg_head").click(function(){
$(this).next(".msg_body").slideToggle(600);
});
});
</script>
<style type="text/css">
.msg_head {
padding: 5px 10px;
cursor: pointer;
position: relative;
background-color:#F4F4F8;
color:Blue;
margin:1px;
}
.msg_body {
padding: 5px 10px 15px;
background-color:#F4F4F8;
}
</style>
</head>
在 body 标签中,您必须放置此代码。
<body>
<p class="msg_head">your titel</p>
<div class="msg_body">
Your logic
</div>
</body>
我真的希望这对你有用。
关于c# - ASP.NET初学者问题: How do I implement something like this is my ASP. NET C#网站?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3649901/