2015-01-21 34 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"); 
} 
相关问题