在GridWeb页面更改时执行客户端函数

可能的使用场景

有时需要在GridWeb页面更改时执行客户端函数。Aspose.Cells.GridWeb提供了OnPageChangeClientFunction属性用于此目的。请将此属性设置为您想要执行的客户端函数。

在GridWeb页面更改时执行客户端函数

以下aspx标记解释了如何使用OnPageChangeClientFunction属性。它使用名为MyOnPageChange的客户端函数设置属性。请注意,此属性仅在启用了分页即EnablePaging=“true"的情况下有效。现在,每当您更改GridWeb页面时,它都会调用客户端函数MyOnPageChange,该函数在控制台上打印当前页面索引,如屏幕截图所示。

todo:image_alt_text

示例代码

这是客户端函数MyOnPageChange的代码,它将因GridWeb中设置OnPageChangeClientFunction=“MyOnPageChange"属性而执行。这是完整的aspx页面标记。

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="CallClientsideScriptforGridWeb.aspx.cs" Inherits="Aspose.Cells.GridWeb.Examples.CSharp.GridWebBasics.CallClientsideScriptforGridWeb" %>
<%@ Register TagPrefix="acw" Namespace="Aspose.Cells.GridWeb" Assembly="Aspose.Cells.GridWeb" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test GridWeb</title>
<script type="text/javascript" >
function MyOnPageChange(index) {
console.log("current page is:" + index);
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div>
<b>GridWeb Version:&nbsp </b>
<asp:Label ID="lblVersion" runat="server" Text="Label"></asp:Label>
<br />
</div>
<acw:GridWeb ID="gridweb"
runat="server" XhtmlMode="True"
Height="504px" Width="1119px" EnablePaging="true"
OnPageChangeClientFunction ="MyOnPageChange">
</acw:GridWeb>
</div>
</form>
</body>
</html>