找回密码
 立即注册

QQ登录

只需一步,快速开始

ilixiaojun
高级会员   /  发表于:2012-6-11 13:53  /   查看:7250  /  回复:3
http://gcdn.grapecity.com/showtopic-4781.html
  1. <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Uc_TestReportModelOfSpread_View.ascx.cs"
  2.     Inherits="GNC.Web.UserControls.TDM.TestManage.TestReportModelOfSpread.Uc_TestReportModelOfSpread_View" %>
  3. <%@ Register Assembly="FarPoint.Web.Spread" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>

  4. <script language="javascript" type="text/javascript">

  5.     //清空Spread单元格选定状态
  6.     function ClearSelectionStatus() {
  7.         var spread = document.getElementById('<%=FpSpread1.ClientID %>');
  8.         //获取spread对象
  9.         spread.ClearSelection();
  10.         spread.Update();
  11.     }
  12. </script>

  13. <asp:Label ID="lblMessage" CssClass="TDM_ErrorMessage" EnableViewState="False" runat="server" ForeColor="Red"></asp:Label>
  14. <FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid"
  15.     BorderWidth="1px" Height="200" Width="400">
  16.     <CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
  17.         ButtonShadowColor="ControlDark">
  18.     </CommandBar>
  19.     <Sheets>
  20.         <FarPoint:SheetView SheetName="Sheet1">
  21.         </FarPoint:SheetView>
  22.     </Sheets>
  23. </FarPoint:FpSpread>
  24. <input type="button" id="btnClearSelection" onclick="ClearSelectionStatus()" value="清空" />
复制代码

这是我的代码,当使用“清空”按钮去调用ClearSelectionStatus方法没有问题,想要的功能也可以实现,可我后台调用该方法提示此对象不包含此属性或此方法(方法为ClearSelection),spread.ClearSelection();js错误,通话清空按钮去调用就没有问题。
并且通过var spread = document.getElementById('<%=FpSpread1.ClientID %>');获取到的spread对象不是null,是pread对象。
我后台是这样调用的ScriptManager.RegisterStartupScript(this, this.GetType(), "ClearSelectionStatus", "ClearSelectionStatus();", true);
未命名11111111111111111.JPG (41.78 KB, 下载次数: 501)

3 个回复

倒序浏览
iceman
社区贡献组   /  发表于:2012-6-11 15:32:00
沙发
回复 1楼ilixiaojun的帖子

ilixiaojun 你好,
可以使用标准控件 button 下 onclientclick 属性调用前台方法调用 ClearSelection() 功能:

  1. <script language="javascript" type="text/javascript">
  2.         function buttonclick() {
  3.             this.FpSpread1.ClearSelection();
  4.             this.FpSpread1.Update();
  5.         }
  6. </script>
  7. <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" onclientclick="buttonclick()" />
复制代码
回复 使用道具 举报
ilixiaojun
高级会员   /  发表于:2012-6-11 16:04:00
板凳
回复 2楼iceman的帖子

我刚开始就是使用标准button 的clientclick,错误时一样的,不过我在body 的onload中调用,问题就解决了,不过谢谢iceman耐心解答。
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-6-11 16:08:00
地板
回复 3楼ilixiaojun的帖子

谢谢 ilixiaojun  的反馈,看来就是调用时机的问题。
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 立即注册
返回顶部