根据JS判断是否执行C#后台代码(后台弹出确定/取消提示窗口)

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/uianqian/article/details/8609114

 protected void LiteButtonArchive_Click(object sender, EventArgs e)
        {
            IList<string> idList = new List<string>();
            foreach (UltraGridRow row in this.UltraWebGridDocument.Rows)
            {
                if (bool.Parse(row.Cells.FromKey("CheckBoxFlag").Value.ToString()))
                {
                    idList.Add(row.Cells.FromKey("Id").Value.ToString().Trim());
                }
            }
            if (idList.Count == 0)
            {
                this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "Ceshi('没有选择要修改的行,是否继续操作');", true);
            }
            else
            {
                //**其他内容
            }
        }


 
 

在HTML代码中使用隐藏的button:<asp:Button runat="server" ID="ButtonArchive" Style="display: none" OnClick="ButtonArchive_Click" />

JS代码内容

function Ceshi(message) {
	    debugger;
	    if (confirm(message)) {
	        $get("<%=ButtonArchive.ClientID %>").click();
	    }
	    else {
	        alert("选择了取消操作");
	    }
	}


通过JS调用ButtonArchive的Click事件,但不能通过JS调用后台的方法,否则还是先执行方法,最后才执行JS

protected void ButtonArchive_Click(object sender, EventArgs e)
{
   / /选择确定之后要做的事情
}




猜你喜欢

转载自blog.csdn.net/uianqian/article/details/8609114
今日推荐