Example #1
0
	protected void Page_Load(object sender, System.EventArgs e)
	{
		// Set the title.
		LinkTable1.Title = "A List of Links";

		// Set the hyperlinked item list.
		LinkTableItem[] items = new LinkTableItem[3];
		items[0] = new LinkTableItem("Test Item 1", "http://www.apress.com");
		items[1] = new LinkTableItem("Test Item 2", "http://www.apress.com");
		items[2] = new LinkTableItem("Test Item 3", "http://www.apress.com");
		LinkTable1.Items = items;

	}
Example #2
0
	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);
			}
		}
	}
Example #3
0
		public LinkTableEventArgs(LinkTableItem item)
		{
			selectedItem = item;
		}