protected void LinkClicked(object sender, LinkTableEventArgs e) { lblInfo.Text = "You clicked '" + e.SelectedItem.Text + "' but this page chose not to direct you to '" + e.SelectedItem.Url + "'."; e.Cancel = true; }
protected void gridLinkList_LinkClicked(object sender, GridViewCommandEventArgs e) { if (LinkClicked != null) { // Get the LinkButton object that was clicked. LinkButton link = (LinkButton)e.CommandSource; // Construct the event arguments. LinkTableItem item = new LinkTableItem(link.Text, link.CommandArgument); LinkTableEventArgs args = new LinkTableEventArgs(item); // Fire the event. LinkClicked(this, args); // Navigate to the link if the event recipient didn't // cancel the operation. if (!args.Cancel) { Response.Redirect(item.Url); } } }
protected void listContent_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e) { if (LinkClicked != null) { // Get the HyperLink object that was clicked. LinkButton link = (LinkButton)e.Item.Controls[1]; // Construct the event arguments. LinkTableItem item = new LinkTableItem(link.Text, link.CommandArgument); LinkTableEventArgs args = new LinkTableEventArgs(item); // Fire the event. LinkClicked(this, args); // Navigate to the link if the event recipient didn't // cancel the operation. if (!args.Cancel) { Response.Redirect(item.Url); } } }