【问题标题】:scroll to Div after OnClick event (c#)OnClick 事件后滚动到 Div (c#)
【发布时间】:2018-10-07 12:56:14
【问题描述】:

我确实有一个链接按钮,可以在 c# 上执行一些代码隐藏。

我希望,在代码隐藏完成后,结果返回到页面,滚动移动到某个 div。

<html>
<head>
</head>
<body>

<asp:LinkButton ID="lb1" runat="server" OnClick="lb1_Click"> Click Aqui </asp:LinkButton>


<div id=myDiv> Hi! </div>

</body>
</html>

后面的代码:

protected void lb1_Click(object sender, EventArgs e)
{
    //do something in database
   // then back to the page, and scroll to MyDiv
}

【问题讨论】:

    标签: c# html asp.net


    【解决方案1】:

    这可以帮助你,只需在 javascript 中更改具有代码的文件,它就会输出文件中调用的内容

    <script type="text/javascript">
    function lb1_Clicks() {
    			$.ajax({
    				url: "getInfo.php",//set the file that will do the magic output
    				success: function(response) {
    					$('.myDiv').html(response).fadeIn();
    				}
    			});
    
    }
    		
    </script>
    <html>
    <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    </head>
    <body>
    
    <asp:LinkButton ID="lb1" runat="server" OnClick="lb1_Click()"> Click Aqui </asp:LinkButton>
    
    
    <div class="myDiv"><!-- your code will update here || example hello World--></div>
    
    </body>
    </html>

    <!-- getInfo.php -->
    <?PHP
    echo "hello world";
    ?>

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-03-21
      • 2012-05-13
      • 1970-01-01
      • 2018-06-01
      • 2013-05-06
      • 1970-01-01
      相关资源
      最近更新 更多