New to Telerik UI for ASP.NET AJAXStart a free 30-day trial

OnClientTileSelected

The OnClientTileSelected event is raised after a tileis selected. It is fired after the OnClientTileSelecting event, if the latter has not been cancelled. This event is also cancellable.

OnClientTileSelected can be used to cancel the postback (if AutoPostBack is true), but still allows the tile to be selected. Cancelling this event will prevent the postback, but not the selection.

The event handler receives two arguments:

  1. the RadTileList object that fired the event

  2. an event arguments object that exposes the following methods

OnClientTileSelected event arguments object

NameReturn typeArgumentsDescription
get_cancel()boolGets a value that indicates whether the event is cancelled.
get_tile()RadBaseTile client-side objectGets a reference to the tile that is about to be selected.
get_value()boolReturns true if the tile is selected.
set_cancel(value)boolSets whether the event will be cancelled (if true is passed).

The following code snippet shows how to get information about a selected tile through the methods exposed by the OnClientTileSelected event's arguments. Note that selection is performed by right-clicking on a tile.

JavaScript
<telerik:RadTileList RenderMode="Lightweight" runat="server" ID="RadTileList1" AutoPostBack="false" OnClientTileSelected="OnClientTileSelected" SelectionMode="Single">
	<Groups>
		<telerik:TileGroup>
			<telerik:RadTextTile Name="Sample Text Tile" Text="Lorem ipsum dolor sit amet" Title-Text="Sample"></telerik:RadTextTile>
		</telerik:TileGroup>
	</Groups>
</telerik:RadTileList>
<div id="myDiv"></div>

<script type="text/javascript">
	function OnClientTileSelected(tileList, args) {
		var tile = args.get_tile();
		var myDiv = document.getElementById("myDiv");
			
		//print tile data
		var log = String.format("Tile with name {0} has been selected; navigateUrl: {1}; selected: {2}; <br />", 
				tile.get_name(), tile.get_navigateUrl(), tile.get_selected());
		myDiv.innerHTML = log;
	}
</script>

The example below demonstrates how the get_value() method exposed by the OnClientTileSelected event arguments can be used to determine whether a tile is selected or deselected.

JavaScript
<telerik:RadTileList RenderMode="Lightweight" runat="server" ID="RadTileList1" AutoPostBack="true" SelectionMode="Single" OnClientTileSelected="OnClientTileSelected">
	<Groups>
		<telerik:TileGroup>
			<telerik:RadTextTile Name="Sample Text Tile" Text="Lorem ipsum dolor sit amet" Title-Text="Sample" NavigateUrl="https://www.telerik.com"></telerik:RadTextTile>
		</telerik:TileGroup>
	</Groups>
</telerik:RadTileList>

<script type="text/javascript">
	function OnClientTileSelected(tileList, args) {
		var selected = args.get_value();

		if (selected) {
			alert("Tile is now checked.");
			var response = confirm("Do you want to post the page now that the tile is selected?");
			args.set_cancel(!response);//the postback can now be cancelled, not the tile selection
		}
		else {
			alert("Tile is now unchecked.");
		}
	}
</script>
Not finding the help you need?
Contact Support