Click here to Skip to main content
15,891,692 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Yes, I know this question has been asked millions of times but the answers I am getting is just not what I am looking for,

This is my code
JavaScript
     <script>
            $("#button").click(function () {
                $('html,body').animate({
                    scrollTop: $(".second").offset().top
                },
                    'slow');
            });
    </script>


This is a my button
HTML
<button type="button" id="button">Click Me!</button>


The code works well but I would like to instead of using a normal html button, use a asp button (I need an asp button for c# code purposes). Is there any way for me to adjust the code ive got not to work with an asp button?

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 15-Nov-13 2:39am    
What "ASP button"? Normal ASP.NET buttons are rendered as regular HTML buttons, nothing else. And how is it related to scroll?
—SA
Member 10395722 15-Nov-13 2:50am    
This is an asp button
<pre lang="HTML"><asp:button id="theID" runat="server" text="button" cssclass="class" onclick="theID_Click" xmlns:asp="#unknown" /></pre>

I am using this, the other <button></button> does not have an OnClick method that I can use in c#
Er Daljeet Singh 15-Nov-13 7:12am    
if you to use asp button then do on thing
Go to source file and in the page directive add a attribute "MaintainScroolBackPosition=true"
this property will maintain the position of scrollback on postback.

1 solution

If you are submit data on server side then add attribute "MaintainScroolBackPosition=true" at page directive section
else please tried with below code


XML
<script>
           $("#<%=buttonID.ClientID%>").click(function () {
               $('html,body').animate({
                   scrollTop: $(".second").offset().top
               },
                   'slow');
           });
   </script>
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900