Hi friends, today i am going show you how to convert given number to word in asp.net c#.
In most of the website, application it is required to convert the number or amount in words. Following code will help you to convert a given number into words. For example, if “1234″ is given as input, output would be “One Thousand Two Hundred Thirty Four Only”.
In most of the website, application it is required to convert the number or amount in words. Following code will help you to convert a given number into words. For example, if “1234″ is given as input, output would be “One Thousand Two Hundred Thirty Four Only”.
Screen 1 |
Screen 2 |
HTML :
<div style="width: 100%; height: auto;" align="center">
<div style="width: 560px; height: auto; background-color: lightgray; margin: 50px;
padding: 25px;">
<h1 style="margin-bottom:50px;">
How to convert given number to word in asp.net c#
</h1>
<table style="width: 60%;">
<tr>
<td>
Input Number
</td>
<td>
<asp:TextBox ID="txtNumber" runat="server" style="width:160px; height:25px; padding:5px;"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnConvert" Text="Convert To Words" runat="server" style="height:25px; width:auto; padding: 0px 10px;" OnClick="btnConvert_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lbl2Way" runat="server" style="color:Green;"></asp:Label>
</td>
</tr>
</table>
</div>
</div>
<div style="width: 560px; height: auto; background-color: lightgray; margin: 50px;
padding: 25px;">
<h1 style="margin-bottom:50px;">
How to convert given number to word in asp.net c#
</h1>
<table style="width: 60%;">
<tr>
<td>
Input Number
</td>
<td>
<asp:TextBox ID="txtNumber" runat="server" style="width:160px; height:25px; padding:5px;"></asp:TextBox>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="btnConvert" Text="Convert To Words" runat="server" style="height:25px; width:auto; padding: 0px 10px;" OnClick="btnConvert_Click" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="lbl2Way" runat="server" style="color:Green;"></asp:Label>
</td>
</tr>
</table>
</div>
</div>
C# Button Click Event :
//Here You need to import this package and Num2Wrd class NumberToEnglish file. You can download class file from below link.
using Num2Wrd;
protected void btnConvert_Click(object sender, EventArgs e)
{
NumberToEnglish no = new NumberToEnglish();
string currency = no.changeCurrencyToWords(Convert.ToInt64(txtNumber.Text.Trim()));
lbl2Way.Text = currency.ToString().ToUpper();
}
{
NumberToEnglish no = new NumberToEnglish();
string currency = no.changeCurrencyToWords(Convert.ToInt64(txtNumber.Text.Trim()));
lbl2Way.Text = currency.ToString().ToUpper();
}