This is a migrated thread and some comments may be shown as answers.

Clicking a link in RadGrid using Javascript

1 Answer 188 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jesuraja
Top achievements
Rank 1
Jesuraja asked on 21 Jan 2015, 07:09 AM


I bind records using RadGrid, and each row it has a link
button. If I click the link, it will open the moalpopup (it is dynamic
one based on some condition). When I close the popup using close button,
it should continue with the link button event.

Code Behind:

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
}

I tried with the above code, the attribute not removed and not continue with link button event.

1 Answer, 1 is accepted

Sort by
0
Jesuraja
Top achievements
Rank 1
answered on 21 Jan 2015, 07:38 AM

Finally I have done. This one worked perfectly as I expected.

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

Tags
Grid
Asked by
Jesuraja
Top achievements
Rank 1
Answers by
Jesuraja
Top achievements
Rank 1
Share this question
or