Hi Dof:
我现在又遇到一个问题,现在在火狐中,页面中有:ScriptManager和UpdatePanel。这样实现页面无刷新。
但是,我在页面中增加一个按钮,来实现新增行用的(后台新增行)。这样新增加一行后,之前的Js事件DataChanged
就会失效。但是,使用表格自带的新增行就不会失效。我的项目要求是要通过外部按钮来新增行.
说明:在IE浏览器不会失效的。(我现在项目要使用火狐浏览器)
以下为代码:
前台代码:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="TabDemo.WebForm11" %>
<%@ Register Assembly="FarPoint.Web.Spread" Namespace="FarPoint.Web.Spread" TagPrefix="FarPoint" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<link href="JavaScripts/calendar.css" rel="stylesheet" type="text/css" />
<script src="JavaScripts/calendar.js" type="text/javascript"></script>
<script src="JavaScripts/calendar-zh.js" type="text/javascript"></script>
<script src="JavaScripts/calendar-setup.js" type="text/javascript"></script>
<script language="javascript" type="text/javascript" id="FpSpread1_Script0">
function FpSpread1_DataChanged(event) {
alert("OK");
}
function CallBackStart(event) {
event.async = true;
}
window.onload = function () {
var spread = document.getElementById("FpSpread1");
if (spread != null) {
if (document.all) {
if (spread.addEventListener) {
spread.addEventListener("CallBackStart", CallBackStart, false);
spread.addEventListener("DataChanged", FpSpread1_DataChanged, false);
} else {
spread.onCallBackStart = CallBackStart;
spread.onDataChanged = FpSpread1_DataChanged;
}
}
else {
spread.addEventListener("CallBackStart", CallBackStart, false);
spread.addEventListener("DataChanged", FpSpread1_DataChanged, false);
}
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" >
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" Height="344px" Width="806px">
<CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
ButtonShadowColor="ControlDark">
<Background BackgroundImageUrl="SPREADCLIENTPATH:/img/cbbg.gif"></Background>
</CommandBar>
<Sheets>
<FarPoint:SheetView SheetName="Sheet1">
</FarPoint:SheetView>
</Sheets>
<TitleInfo BackColor="#E7EFF7" ForeColor="" HorizontalAlign="Center" VerticalAlign="NotSet" Font-Size="X-Large"></TitleInfo>
</FarPoint:FpSpread>
<br />
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button"
Width="94px" />
<br />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
后台代码:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace TabDemo
{
public partial class WebForm11 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
this.FpSpread1.Sheets[0].AllowDelete = true;
this.FpSpread1.Sheets[0].AllowInsert = true;
this.FpSpread1.Sheets[0].RowCount = 0;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
this.FpSpread1.Sheets[0].AddRows(this.FpSpread1.Sheets[0].RowCount, 1);
}
}
}
以上,请帮忙看一下。感谢了。 |
|