2015-01-21 67 views
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 
} 

我試着用上面的代碼,不會被刪除的屬性,而不是與鏈接按鈕事件繼續。

回答

0

最後我已經完成了。這一個完美如我所料。

function proceed(id) 
{ 
    document.location.href = $('#' + id).attr("href"); 
} 
相關問題