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)
{
/ /選擇確定之後要做的事情
}