OnClick事件后滚动到Div(C#)

时间:2018-10-07 02:30:56

标签: c# html asp.net

我确实有一个linkbutton,可以在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
}

1 个答案:

答案 0 :(得分:0)

这可以为您提供帮助,只需在javascript中更改包含代码的文件,它就会将文件中的内容输出

<ion-header>
  <ion-navbar>
    <ion-title>{{ 'page_dashboard_title' | translate }}</ion-title><button class="navbtn" right (click)="openMenu()"><ion-icon name="menu"></ion-icon></button>
  </ion-navbar>
</ion-header>

<ion-content padding>
   <div class="scan-container">
      <img src="../assets/imgs/scan.png"/>
      <div class="info">


         <h4 (click)="scanCode()" >Scan the QR code</h4>

         <p>Please scan the QR code from you ticket. So we can import ticket details.</p>
      </div>
   </div>
   <button ion-button full (click)="GotoAddBunndlePage()">Manual Entry</button>
</ion-content>
<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>