A toggle button is a specicalized button which can be selected. Thus, it can be counted as a button control that allows user to change a setting between two states. And the PerButton control can not only allow users to create a toggle button in ASP.NET web application using C#.NET programming code but also enable users to customize the appearance styling of created toggle button. And now the PerButton control has been used in the ASP.NET web projects which need many checkbox buttons or radio buttons or other customized toggle buttons.
From this article, you will find detailed Visual C# .NET programming codes for building and creating a fully customized toggle button in asp.net web application. Before following the sample programming guidance listed below, please make sure that your ASP.NET web application has installed NET Framework 3.5 or above versions and that you have installed all the necessary dlls from our ASP.NET AJAX SDK into your ASP.NET web application. Set Button Type Using C# Code
The PerButton offers several options for the Button Type properties, including ToggleButton, StandardButton, LinkButton and SkinnedButton. Here you need to set the button type to ToggleButton. btnSeason.ButtonType = PerButtonType.ToggleButton; Define Toggle Type Using C# Code
To make sure that users can create a toggle button whose appearance is fully tailored at their requests, the PerButton control also provides three available options for the Toggle Type property, which are CheckBox, Radio and CustomToggle. btnSeason.ToggleType = ButtonToggleType.CustomToggle; Customize the Button Size Using C# Code
The width & height of the toggle button can be accurately defined using following C# code. btnSeason.Width = 100; Set the Toggle State Using C# Code
The property ToggleState is responsible for the button state after it is clicked. In following C# code, we add 4 states to the toggle button. The initial value of the ToggleState property is spring. After the first click, the background image of the button will be changed to summer and the text on the button will be changed at the same time. After the second click, the background image of the button and the text on the button will change to the autumn. With the third click, the background image of the button and the text on the button will be changed to winter. And when the background image of button becomes the winter, one click on the button will make the button return to the initial value of spring. PerButtonToggleState toggleState1 = newPerButtonToggleState(); | ![]() ASP.NET AJAX UI Controls ASP.NET AJAX Chart UI Control ASP.NET AJAX Grid UI Control ASP.NET AJAX Barcode UI Control ASP.NET AJAX Button UI Control OverviewGetting StartedButton Type Standard ButtonIcon ButtonImage ButtonLink ButtonToggle ButtonSplit ButtonClient Prpgramming Button EventServer Programming Button EventASP.NET AJAX Calendar UI Control ASP.NET AJAX NavigationBar UI Control ASP.NET AJAX Captcha UI Control ASP.NET AJAX Color Editor UI Control ASP.NET AJAX ComboBox UI Control ASP.NET AJAX DataPager UI Control ASP.NET AJAX Dock UI Control ASP.NET AJAX DropDownList UI Control ASP.NET AJAX DropDownTree UI Control ASP.NET AJAX HtmlEditor UI Control ASP.NET AJAX FileManager UI Control ASP.NET AJAX Filter UI Control ASP.NET AJAX Input UI Control ASP.NET AJAX ListBox UI Control ASP.NET AJAX ListView UI Control ASP.NET AJAX ToolBar UI Control ASP.NET AJAX TabControl UI Control ASP.NET AJAX Menu UI Control ASP.NET AJAX ToolTip UI Control |