click on load more button when user click on bottom

Last Reply on Mar 04, 2016 08:08 AM By Shashikant

Posted on Mar 01, 2016 04:13 AM

hi,

 

i have link button at last of page when user click on link button it clicks more data.

 

what i want is when user reach on bottom so load more button click automatically.

Posted on Mar 03, 2016 10:21 AM Modified on on Mar 03, 2016 10:22 AM

Hi,

Please refer below code.

HTML

<div>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
    <script type="text/javascript">
        $(function () {
            $('[id*=LinkButton7]').hide();
            $(window).scroll(function () {
                if ($(document).scrollTop() + $(window).height() >= $("body").height()) {
                    $('[id*=LinkButton7]').show();
                }
            })          
        });
    </script>
    <asp:ListView ID="ListView1" runat="server">
        <ItemTemplate>
            <asp:Label ID="Label2" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "MyProductId") %> '
                Visible="false"></asp:Label>
            <div class="white-panel">
                <%--<img src="http://i.imgur.com/sDLIAZD.png" alt="">--%>
                <asp:ImageButton ID="ImageButton2" ImageUrl='<%# DataBinder.Eval(Container.DataItem, "Image") %> '
                    CssClass="img" CommandName="ViewProduct" runat="server" />
                <p style="text-transform: capitalize; font-size: 11px; text-align: left;">
                    <asp:Label ID="Label1" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "UserName") %> '
                        Font-Bold="True"></asp:Label>
                    <asp:Label ID="Label3" runat="server" Text="wants"></asp:Label>
                    <asp:LinkButton ID="LinkButton4" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Description") %> '
                        ForeColor="#333333" Font-Italic="True" CommandName="ViewProduct"></asp:LinkButton>
                    and what make it special is
                    <asp:LinkButton ID="LinkButton6" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "Special") %> '
                        ForeColor="#333333" Font-Italic="True"></asp:LinkButton>
                    <asp:LinkButton ID="LinkButton8" runat="server" CssClass="text-danger pull-right"
                        Font-Size="X-Small" ForeColor="#9900CC" CommandName="ViewProduct">View</asp:LinkButton></p>
                <hr />
                <div class="row">
                    <div class="col-xs-3" style="padding: 0px;">
                        <asp:LinkButton ID="LinkButton3" runat="server" CommandName="favorite" ForeColor="White"
                            Font-Size="X-Small" CssClass="btn btn-warning pull-left"> <span class="glyphicon glyphicon-heart" aria-hidden="true"></span> <%# DataBinder.Eval(Container.DataItem, "fav") %> </asp:LinkButton>
                    </div>
                    <div class="col-xs-3" style="padding: 0px;">
                        <i class="fa fa-eye btn btn-success">
                            <asp:Label ID="Label5" runat="server" Text='<%# DataBinder.Eval(Container.DataItem, "totalviews") %> '
                                Font-Size="X-Small"></asp:Label></i>
                    </div>
                    <div class="col-xs-3" style="padding: 0px;">
                    </div>
                    <div class="col-xs-4" style="padding: 0px;">
                        <asp:LinkButton ID="LinkButton5" runat="server" CssClass="text-danger pull-right"
                            Font-Size="X-Small">Report Spam</asp:LinkButton>
                    </div>
                </div>
            </div>
        </ItemTemplate>
    </asp:ListView>
    <div class="loadmore">
        <asp:LinkButton ID="LinkButton7" runat="server" OnClick="LinkButton7_Click" ForeColor="#333333">Load More</asp:LinkButton>
        <asp:DataPager ID="DataPager2" runat="server" PagedControlID="ListView1" PageSize="20">
            <Fields>
                <asp:NextPreviousPagerField ButtonType="Image" ShowPreviousPageButton="false" PreviousPageText=""
                    NextPageText="Load More" Visible="False" />
            </Fields>
        </asp:DataPager>
    </div>
</div>

I hope this will help you out.

 


Posted on Mar 04, 2016 08:08 AM

You need to use below code.

Javascript

javascript: __doPostBack('<%= LinkButton7.UniqueID %>', '')

to post back after document reach the bottom,but you need to rebind data to Datalist.