找回密码
 立即注册

QQ登录

只需一步,快速开始

zhu_99031

银牌会员

9

主题

29

帖子

3586

积分

银牌会员

积分
3586

活字格认证

zhu_99031
银牌会员   /  发表于:2012-2-20 15:30  /   查看:10680  /  回复:13
protected void FSCompany_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
    {
        var rowindex = FSCompany.ActiveSheetView.SelectionModel.AnchorRow;
        var columnindex = FSCompany.ActiveSheetView.SelectionModel.AnchorColumn;

        RuletblEQIP_C_CompanyInfo ruleCompany = new RuletblEQIP_C_CompanyInfo();

        FarPoint.Web.Spread.SheetView sv = new FarPoint.Web.Spread.SheetView();
        string cellStype = e.CommandName;
        switch (cellStype)
        {
            case "delete":
                if (ruleCompany.Delete(int.Parse(this.FSCompany.ActiveSheetView.GetValue(rowindex, 1).ToString())))
                {
                    this.Response.Write("<script>alert('删除成功')</script>");
                    this.FSCompany.ActiveSheetView.RemoveRows(rowindex, 1);
                }
                else
                    base.RegistMessage("企业删除失败");
                break;
        }
    }

请问我这样写为什么提示框 弹不出来啊?

13 个回复

正序浏览
iceman
社区贡献组   /  发表于:2012-7-18 17:02:00
14#
回复 13楼zhu_99031的帖子

客气了
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-7-18 16:59:00
13#
谢谢版主:strong:
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-7-18 16:30:00
12#
回复 11楼zhu_99031的帖子

zhu_99031 你好,
不必客气,这是我应该做的。
现在的情况是使用 HTML Button 调用后台 Buttom_Command,由于 Spread 内部实现机制限制。 无法弹出提示框。
建议,使用 ASP.NET 标准控件 Server 端 Button 代替 HTML Button,设置以下代码:

  1. WebControl serverButton = this.FindControl(&quot;Button1&quot;) as WebControl;
  2.         serverButton.Attributes.Add(&quot;onclick&quot;, ClientScript.GetPostBackEventReference(FpSpread1, &quot;Button,-1,-1&quot;) + &quot;; return false;&quot;);
复制代码
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-7-18 09:24:00
11#
是的
麻烦版主了.
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-7-17 18:12:00
10#
回复 9楼zhu_99031的帖子

zhu_99031 你好,
确认下需求:
1.点击第三列添加单击事件执行前台 js 方法?
2.点击 Html button(在楼主的 Demo 中 Name 为 Button,为 Html button)执行后台 Button_Command 弹出提示框?
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-7-17 16:29:00
9#
还是不行, 这样写单击第三列时会弹出提示, 但是外面的button 事件弹出不了提示框
我现在是第三列添加单击事件执行其他脚本方法, 而button 要是调用 FpSpread1_ButtonCommand 执行后台程序, 然后再 弹出提示框.
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-7-17 15:39:00
8#
回复 7楼zhu_99031的帖子

请使用以下代码测试:

  1. protected void Page_Load(object sender, EventArgs e)
  2.     {

  3.     }
  4.     protected override void Render(HtmlTextWriter writer)
  5.     {
  6.         Table viewPort = this.FpSpread1.FindControl("viewPort") as Table;
  7.         for (int i = 0; i < viewPort.Rows.Count; i++)
  8.         {
  9.             for (int j = 0; j < viewPort.Rows[i].Cells.Count; j++)
  10.             {
  11.                 if (j == 3)
  12.                 {
  13.                     viewPort.Rows[i].Cells[j].Attributes.Add("onclick",
  14.                         ClientScript.GetPostBackEventReference(FpSpread1, "Button,-1,-1") + "; return false;");
  15.                 }
  16.             }
  17.         }
  18.         base.Render(writer);
  19.     }
  20.     protected void FpSpread1_ButtonCommand(object sender, FarPoint.Web.Spread.SpreadCommandEventArgs e)
  21.     {
  22.         string cellStype = e.CommandName;
  23.         switch (cellStype)
  24.         {
  25.             case "Button":
  26.                 ClientScript.RegisterStartupScript(this.GetType(), "newwin", "<script type ='text/javascript'> alert('测试')</script>");
  27.                 break;
  28.         }
  29.     }
复制代码
回复 使用道具 举报
zhu_99031
银牌会员   /  发表于:2012-7-17 11:40:00
7#
demo 已上传
demo.rar (1.83 MB, 下载次数: 1413)
回复 使用道具 举报
iceman
社区贡献组   /  发表于:2012-7-16 17:47:00
6#
回复 5楼zhu_99031的帖子

你好,我使用 4# 中的 Demo,操作正常,请楼主发 Demo 到论坛调试。
回复 使用道具 举报
12下一页
您需要登录后才可以回帖 登录 | 立即注册
返回顶部