0
我使用RadGrid綁定記錄,並且每行都有一個鏈接按鈕。如果我點擊鏈接,它會打開moalpopup(根據某些條件它是動態的)。當我使用關閉按鈕關閉彈出窗口時,它應該繼續使用鏈接按鈕事件。使用JavaScript單擊RadGrid中的鏈接
代碼背後:
protected void grid_ItemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item.ItemType == GridItemType.AlternatingItem || e.Item.ItemType == GridItemType.Item)
{
LinkButton link = ((LinkButton)gridDataItem.FindControl("link"));
ModalPopupExtender popup = (ModalPopupExtender)e.Item.FindControl("popup");
Image imageClose = (Image)e.Item.FindControl("imageClose");
popup.TargetControlID = link.ID;
link.Attributes.Add("onclick", "return false;"); // to avoid postback and stay in page and show popup
imageClose.Attributes.Add("onclick", "proceed('" + link.ClientID + "')");
}
}
的Javascript:
function proceed(id)
{
window.document.getElementById(id).removeAttribute("onclick"); // Link button - to remove "onclick" attribute
window.document.getElementById(id).click(); // trigger click event
}
我試着用上面的代碼,不會被刪除的屬性,而不是與鏈接按鈕事件繼續。