Add onclick event to command field in asp.net
asp.net, c#
Solution
Use the `ItemCommand` event:
in code behind:
protected void detailsview1_ItemCommand(Object sender, DetailsViewCommandEventArgs e)
{
if (e.CommandName == "Update")
{
Response.Redirect("abc.aspx", false);
}
}
In aspx:
<asp:DetailsView runat="server"
ID="detailsview1"
OnItemCommand="detailsview1_ItemCommand" ...
Problem
I have this update link in DetailsView. ``` <asp:CommandField ShowEditButton="true" ShowCancelButton="false" ValidationGroup="VAL_1" /> ``` When i click this link, its updates the content on the page. but i want to updates the content on the page and redirect to another page (ex: abc.aspx) after click on this. How could i do this ?