Validate IBAN Using C#

January 5, 2017 Leave a comment

Hi all,

Try this example to Validate IBAN Using C#

public static bool ValidateBankAccount(string bankAccount)
bankAccount = bankAccount.ToUpper(); //IN ORDER TO COPE WITH THE REGEX BELOW
if (String.IsNullOrEmpty(bankAccount))
return false;
else if (System.Text.RegularExpressions.Regex.IsMatch(bankAccount, "^[A-Z0-9]"))
bankAccount = bankAccount.Replace(" ", String.Empty);
string bank =
bankAccount.Substring(4, bankAccount.Length - 4) + bankAccount.Substring(0, 4);
int asciiShift = 55;
StringBuilder sb = new StringBuilder();
foreach (char c in bank)
int v;
if (Char.IsLetter(c)) v = c - asciiShift;
else v = int.Parse(c.ToString());
string checkSumString = sb.ToString();
int checksum = int.Parse(checkSumString.Substring(0, 1));
for (int i = 1; i < checkSumString.Length; i++)
int v = int.Parse(checkSumString.Substring(i, 1));
checksum *= 10;
checksum += v;
checksum %= 97;
return checksum == 1;
return false;

Hope this helps

Good Luck

Categories: ASP.Net

Get Current Page Name

December 6, 2016 Leave a comment

Hi all,

Try this example to Get Current Page Name

public static string GetCurrentPageName()
string sPath = HttpContext.Current.Request.Url.AbsolutePath;
System.IO.FileInfo oInfo = new System.IO.FileInfo(sPath);
string sRet = oInfo.Name;
return sRet;

Hope this helps

Good Luck.

Categories: ASP.Net

Validate Rad ComboBox

November 6, 2016 Leave a comment

Hi all,

Try this example to Validate Rad ComboBox Using ASP.Net Validation Controls

<script type="text/javascript">
 function validateddlType(source, args) {
 args.IsValid = false;
 var combo = $find("<%= ddlType.ClientID %>");
 var text = combo.get_text();
 if (text.length < 1) {
 args.IsValid = false;
 else {
 var node = combo.findItemByText(text);
 if (node) {
 args.IsValid = true;
 else {
 args.IsValid = false;


<telerik:radcombobox id="ddlType" allowcustomtext="True" runat="server" emptymessage="--- Please Select ---" filter="Contains" skin="Telerik"></telerik:radcombobox>
<asp:RequiredFieldValidator ID="rfvType" ControlToValidate="ddlType" ForeColor="Red" runat="server" Display="Dynamic" ErrorMessage="Value is required" ValidationGroup="A"></asp:RequiredFieldValidator>
<asp:CustomValidator ID="cvType" ClientValidationFunction="validateddlType" ForeColor="Red" ControlToValidate="ddlType" ValidationGroup="A" runat="server" ErrorMessage="Please select a vaild Value"></asp:CustomValidator>

Hope this helps

Good Luck.

Categories: ASP.Net, Javascript

Display Images in RadioButtonList Control in ASP.NET

October 20, 2016 Leave a comment

Hi all,

Try this example to Display Images in RadioButtonList Control in ASP.NET

You can also check my previous posts

Bind RadioButtonList with Image from Database

Bind RadioButtonList to Image

Step 1: Create a new ASP.NET Web Application in Visual Studio. Add a folder in the root named Images. Right-click on the project name and select:

Add -> New Folder

Now add some images in this folder to show with RadioButtons in the RadioButtonList control. Right-click on the Images folder and select:

Add -> Existing Item


Step 2: Add a RadioButtonList in HTML source view of Default.aspx, as shown in the following:

<asp:RadioButtonList ID="RadioButtonList1" runat="server"
BorderStyle="Groove" BorderWidth="1px" RepeatColumns="3" RepeatLayout="Table">

RepeatColumns of RadioButtonList is set to “3” to divide its items in three columns. For example if we have 18 items in the RadioButtonList, it will be displayed in 3 columns with 6 RadioButtons in each column.
The RepeatLayout property is used to specify the arrangement of RadioButtons inside the RadioButtonList control. By default or when it is set to “Table”, RadioButtons are rendered in a table but if it is set to “Flow”, it is rendered without a table.

Step 3: Write the following code in the Page Load event of Default.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
ListItem item;
int i = 0;
System.IO.FileInfo file;

var Images =
from n in System.IO.Directory.GetFiles(Server.MapPath("Images"))
orderby n descending
select n;

foreach (var filename in Images)
file = new System.IO.FileInfo(filename);

item = new ListItem("<img src='" + "Images/" + file.Name + "' alt='" + file.Name +
"' title='"+file.Name+"'/>", i.ToString());

RadioButtonList1.CellPadding = 5;
RadioButtonList1.CellSpacing = 5;

Hope this helps

Good Luck.


Categories: ASP.Net

Convert Number to Word In SQL Sever

September 20, 2016 Leave a comment

Hi all,

Try this example to convert number to word in SQL Server

Create FUNCTION [dbo].[NumberToWords]
@Amount bigint
RETURNS nvarchar(max)
declare @Ones table (Id int, Name nvarchar(50))
declare @Decades table (Id int, Name nvarchar(50))
insert into @Ones(Id,Name) values(0,''),(1,'One'),
insert into @Decades(Id,Name) values(20,'Twenty'),(30,'Thirty'),
declare @str nvarchar(max)
set @str=''

if(@Amount >= 1 AND @Amount <20)
set @str=@str+ (select Name from @Ones where Id=@Amount)

if(@Amount >= 20 AND @Amount <=99)
set @str=@str+ (select Name From @Decades where Id=
(@Amount- @Amount%10))+' ' +(select Name From @Ones where Id=(@Amount%10)) +' '

if(@Amount >= 100 AND @Amount <=999)
set @str=@str+ dbo.NumberToWords(@Amount/100) +'
Hundred '+dbo.NumberToWords(@Amount%100)

if(@Amount >= 1000 AND @Amount <=99999)
set @str=@str+ dbo.NumberToWords(@Amount/1000) +'
Thousand '+dbo.NumberToWords(@Amount%1000)

if(@Amount >= 100000 AND @Amount <=9999999)
set @str=@str+ dbo.NumberToWords(@Amount/100000) +'
Lac '+dbo.NumberToWords(@Amount%100000)

if(@Amount >= 10000000 )
set @str=@str+ dbo.NumberToWords(@Amount/10000000) +'
Crore '+dbo.NumberToWords(@Amount%10000000)

return @str

Hope this helps

Good Luck.

Categories: SQL Server

List the Name of the Months Between Date Ranges in SQL Server

August 29, 2016 Leave a comment

Hi all,

Try this example to List the Name of the Months Between Date Ranges in SQL Server

DECLARE @sDate DATETIME = '20160301', @eDate DATETIME = '20160901';

;WITH cte AS
SELECT @sDate AS dates
SELECT DATEADD(mm,1,c.dates)
FROM cte c
WHERE c.dates < @eDate
FROM cte

Hope this helps

Good Luck.

Categories: SQL Server

Allow User to Enter Arabic Characters Or Number Only

July 24, 2016 Leave a comment

Dear all,

Try this example to Validate User to enter Arabic characters or numbers only

<asp:TextBox ID="txt_Name" runat="server"></asp:TextBox>
<asp:RegularExpressionValidator ID="rev_Name" runat="server" ErrorMessage="*" ControlToValidate="txt_Name" ValidationExpression="^[0-9\u0600-\u06FF/ ]+$" ></asp:RegularExpressionValidator>

Hope this helps

Good Luck.

Categories: ASP.Net