【问题标题】:How to alert AfterPerformCallBack如何提醒 AfterPerformCallBack
【发布时间】:2018-10-12 01:22:19
【问题描述】:

代码背后

    protected void ASPxGridView1_AfterPerformCallback(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewAfterPerformCallbackEventArgs e)
    {
        if (e.Args.Count() > 0)
        {
            string[] UID = e.Args[0].Split(':');
            if (UID[0] == "Complete")
            {
                try
                {
                    string id = UID[1];
                    int completeID = Convert.ToInt32(id);
                    using (TaskListDataContext db = new TaskListDataContext())
                    {
                        var list = db.SupportIssues.Where(x => x.UID == completeID).ToList();
                        if (list.Count > 0)
                        {
                            SupportIssue _support = list[0];
                            if (_support.Status != 1)
                            {
                                string uptsql = string.Format("Update dbo.SupportIssues Set Status = 1 Where UID={0}", id);
                                db.ExecuteCommand(uptsql);
                                Page_Init(sender, e);
                                SendCompletedEmail(completeID);
                            }
                            else
                            {
                                 Alert.Show("This issue has been completed");
                            }
                        }

                    }
                }
                catch (Exception ex)
                {
                    Response.Write(ex.Message + ex.StackTrace);
                }

            }

        }
    }

JavaScript

function completeTaskRow(s, e) {
          var keys = grid.GetFocusedRowIndex();
          var id = grid.GetRowKey(keys);
          if (confirm('Mark this issue to complete?')) {
              grid.PerformCallback("Complete:" + id);
          }
      }

如何在AfterPerformCallback 发出警报消息?

尝试了这些解决方案:

  1. Response.Write("alert('...');");
  2. ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('...')", true);
  3. ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "Message", "alert('...');", true);

还是不适合我。

【问题讨论】:

    标签: javascript c# asp.net


    【解决方案1】:

    使用here 中记录的重载。方法如下:

    grid.PerformCallback("Completed:" +id, function(data){
        // do whatever
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-14
      • 1970-01-01
      • 2019-04-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多