HTML:
<form id="form1" runat="server">
<div>
<asp:TextBox ID="txtNumber" runat="server" />
<br />
<asp:Button Text="Convert numbers to words" OnClick="ConvertNumTowords" runat="server" />
<br />
<asp:Label ID="lblWords" runat="server" Visible="false"/>
</div>
</form>
C#:
protected void ConvertNumTowords(object sender, EventArgs e)
{
string[] Ones = { "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Ninteen" };
string[] Tens = { "Ten", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninty" };
int no = Convert.ToInt32(this.txtNumber.Text.Trim());
string strWords = "";
if (no > 99 && no < 1000)
{
int j = no / 100;
strWords = strWords + Ones[j - 1] + " Hundred ";
no = no % 100;
}
if (no > 19 && no < 100)
{
int j = no / 10;
strWords = strWords + Tens[j - 1] + " ";
no = no % 10;
}
if (no > 0 && no < 20)
{
strWords = strWords + Ones[no - 1];
}
this.lblWords.Visible = true;
this.lblWords.Text = strWords;
}