我想隐藏"查看更多"按钮当列表视图中显示所有项目,并显示它显示6乘6项时,它工作正常,但我只想在显示所有行时隐藏按钮,如果有使用jquery的解决方案或在代码隐藏中它的方法很好
这是html
<asp:ListView runat="server" ID="lstCareers">
<LayoutTemplate>
<asp:PlaceHolder runat="server"
ID="ItemPlaceHolder"></asp:PlaceHolder>
</LayoutTemplate>
<ItemTemplate>
<asp:HyperLink runat="server"
ID="HyperLink1" NavigateUrl='<%# Eval("PID")%>'>
<li class="liCareers">
<p class="Vacancies_title">
<asp:Label runat="server"
ID="lblTitle" Text='<%#Eval("Title")%>'></asp:Label>
</p>
<p class="Vacancies_pref">
<asp:Label runat="server"
ID="lblBrief" Text='<%#Eval("Brief")%>'></asp:Label>
</p>
<img
src="../../App_Themes/ThemeEn/Images/DetailsBtn.png" style="float: right;"/>
<br />
</li>
</asp:HyperLink>
</ItemTemplate>
</asp:ListView>
</ul>
<div style="clear: both"></div>
<center style="padding: 20px">
<div class="col-md-2" style="float: none !important;">
<a href="#" id="loadMore">
<asp:label runat="server" ID="lblReadMore" style="font-size: 18px;"></asp:label>
<img src="../../App_Themes/ThemeEn/Images/loadmoreImage.png"/>
</a>
</div>
</center>
这里是负责切片的jquery
<script>
$(function () {
$(".liCareers").slice(0, 5).show();
$("#loadMore").on('click', function (e) {
e.preventDefault();
$(".liCareers:hidden").slice(0, 4).slideDown();
if ($(".liCareers:hidden").length == 0) {
$("#load").fadeOut('slow');
}
$('html,body').animate({
scrollTop
}, 1500);
});
});
</script>
这是css
.liCareers {
display: none;
padding: 10px;
border-width: 0 1px 1px 0;
border-style: solid;
border-color: #fff;
box-shadow: 0 1px 1px #ccc;
margin-bottom: 5px;
background-color: #f1f1f1;
}
这是背后的代码
Protected Sub fillNews()
Try
Using db As New EchoNewWebSiteClassLibrary.EchoNewWebSiteDataClassesDataContext
Dim SelectedNews = From latestnews In db.SelectCareersBySiteID(SessionManager.CurrentSessionManager.SiteID)
Select latestnews
lstCareers.DataSource = SelectedNews.ToList()
lstCareers.DataBind()
End Using
Catch ex As Exception
End Try
End Sub
答案 0 :(得分:0)
当你要找到第一页记录(0到6)然后你需要找到下一页记录(7到12)。如果存在下一页记录,则声明参数( IsMoreRecord )。并传递其中的真或假值。并检查是否 ( IsMoreRecord )为true然后按钮可见,否则按钮可见false。