嗨,dof:
我这边又遇到一个问题,麻烦帮忙解决。
问题就是:当我页面中有一个Asp.net的Menu控件和一个Spread控件时,我的需求是点击菜单中的某个项(如:增加行),这样调用前台的Js方法来新增加表格行。这时,会报一个“物件不支持此属性和方法”的错误.但是我调用其他JS方法是没有问题的。[我是要通过后台调用前台JS方法].
以上问题,请尽快帮忙看看。谢谢!(你测试时就点击菜单项:增加行,就知道问题所在了)
---------------
具体代码:
前台:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm4.aspx.cs" Inherits="opupCellTypeDemo.WebForm4" %>
<%@ Register Assembly="FarPoint.Web.Spread, Version=6.0.3505.2008, Culture=neutral, PublicKeyToken=327c3516b1b18457"
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>
<script type="text/javascript">
function opentest() {
alert("OK");
}
function testotherjs() {
document.getElementById("TextBox1").value = "Js賦值";
}
function testAdd() {
//------------------------
//此處如果是Menu控件點擊調用,就會有問題。會報"物件不支持此屬性或方法"的錯誤
//此處用FpSpread1控件的任意屬性和方法都不行.
//我的需求就是要通過Menu單擊來調用Js方法來新增行.
//請幫忙看看。為什么在Menu下就不行??
//------------------------
FpSpread1.Add();
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal"
onmenuitemclick="Menu1_MenuItemClick">
<Items>
<asp:MenuItem Text="系統" Value="系統">
<asp:MenuItem Text="彈出JS提示" Value="彈出JS提示"></asp:MenuItem>
</asp:MenuItem>
<asp:MenuItem Text="編輯" Value="編輯">
<asp:MenuItem Text="增加行" Value="增加行"></asp:MenuItem>
<asp:MenuItem Text="后臺復值" Value="后臺復值"></asp:MenuItem>
<asp:MenuItem Text="Js賦值" Value="Js賦值"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
<br />
<br />
<br />
<br />
<FarPoint:FpSpread ID="FpSpread1" runat="server" BorderColor="Black" BorderStyle="Solid"
BorderWidth="1px" Height="200" Width="400">
<CommandBar BackColor="Control" ButtonFaceColor="Control" ButtonHighlightColor="ControlLightLight"
ButtonShadowColor="ControlDark">
</CommandBar>
<Sheets>
<FarPoint:SheetView SheetName="Sheet1">
</FarPoint:SheetView>
</Sheets>
</FarPoint:FpSpread>
<aspabel ID="Label1" runat="server" Text="[]"></aspabel>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</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 PopupCellTypeDemo
{
public partial class WebForm4 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Menu1_MenuItemClick(object sender, MenuEventArgs e)
{
string itemvalue = e.Item.Value;
if (itemvalue == "彈出JS提示")
{
ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), "", "opentest();", true);
}
if (itemvalue == "增加行")
{
ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), "", "testAdd();", true);
}
if (itemvalue == "后臺復值")
{
Label1.Text = "后臺復的值";
}
if (itemvalue == "Js賦值")
{
ScriptManager.RegisterStartupScript(Label1, Label1.GetType(), "", "testotherjs();", true);
}
}
}
} |
|