New to Telerik UI for WPFStart a free 30-day trial

Allow Numbers Only in the PageIndex TextBox of RadDataPager

Updated on Sep 15, 2025

Environment

Product Version2019.3.1023
ProductRadDataPager for WPF

Description

Allow entering only numeric input in the DataPagerTextBox that shows the current page index.

Solution

Subscribe to the Loaded event of RadDataPager in order to get the DataPagerTextBox control representing the page index input. Then subscribe to the PreviewTextInput event of DataPagerTextBox. In the handler, you can check the current Text and if there is a non-numeric value, set the Handled property of the event arguments to True. This will cancel the input.

C#
	private void RadDataPager_Loaded(object sender, RoutedEventArgs e)
	{
		var dataPagerTextBox = this.radDataPager.FindChildByType<DataPagerTextBox>();
		dataPagerTextBox.PreviewTextInput += Tb_PreviewTextInput;
	}

	private void DataPagerTextBox_PreviewTextInput(object sender, TextCompositionEventArgs e)
	{
		Regex regex = new Regex("[^0-9]+");
		e.Handled = regex.IsMatch(e.Text);
	}
In this article
EnvironmentDescriptionSolution
Not finding the help you need?
Contact Support