Ajax Toolkit NumericUpDownExtender Control in ASP.Net
That is the NumericUpDownExtender which automatically adds two buttons to a text box: One for increasing its value, one for decreasing it.
NumericUpDown Properties:
TargetControlID - The ID of the TextBox to modify
Width - Combined size of the TextBox and Up/Down buttons. This property is not used if you provide custom buttons.
RefValues - A list of strings separated by semicolons (;) to be used as an enumeration by NumericUpDown Extender
Code:
Add these control on aspx page
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<%--Add the NumericUpDown Extender --%>
<cc1:NumericUpDownExtender ID="NumericUpDownExtender1" runat="server" TargetControlID="TextBox1"Width="200" RefValues="Red;Blue;Green;Brown">
</cc1:NumericUpDownExtender>
<asp:Label ID="Label1" runat="server" Text="Change this text color." Font-Bold="true"Font-Size="Large" Font-Names="Arial"></asp:Label>
<br/><br/><br />
<asp:TextBox ID="TextBox1" runat="server" Font-Bold="true" ForeColor="Blue" BackColor="Azure"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Change Label" Font-Bold="true" OnClick="Button1_Click"Height="30" />
Here TargetControlIDis "TextBox1" in whichUpDownExtender will be apply
Write these codes on Button1 click event
protected void Button1_Click(object sender, EventArgs e)
{
Label1.ForeColor = System.Drawing.Color.FromName(TextBox1.Text);
}
The FromName property will get the color name from TextBox1. TextBox1 Gets the value from RefValues.
Run The Project
When you click up or down button then Next Value will show in the TextBox
When you click Change Color Button then Label Text color will be changed into the selected color.
You should also read this Article :- String Split in C#
Anonymous User
26-Feb-2019Very good Article.
Sushant Mishra
25-Jul-2017