QueryString
Encode & Decode
Helper
Class
public
class
clsQueryString
{
static
public
string
QueryStringEncode(string
value)
{
return
clsEncryptionDecryption.GetEncrypt(value);
}
static
public
string
QueryStringDecode(string
value)
{
return
clsEncryptionDecryption.GetDecrypt(value);
}
public
static
string
GetValueFromQueryString(string
value, string
key)
{
string
strValue = string.Empty;
if
(value != null)
{
string
DataString = clsEncryptionDecryption.GetDecrypt(value);
Hashtable
objHash = clsQueryString.GetQueryString(DataString);
strValue
= clsCheckDBNull.ConvertToStr(objHash[key]);
return
strValue;
}
else
return
"";
}
public
static
Hashtable
GetQueryString(string
DataValue)
{
string[]
AndArray = DataValue.Split(new
Char[]
{ '&'
});
Hashtable
objHash = new
Hashtable();
string[]
splitArray;
try
{
if
(AndArray.Length > 0)
{
for
(int
i = 0; i <= AndArray.Length - 1; i++)
{
splitArray
= AndArray[i].Split(new
Char[]
{ '='
});
objHash.Add(splitArray[0],
splitArray[1]);
}
}
}
catch
(Exception)
{
return
objHash;
}
return
objHash;
}
}
Encode
Query string
Data
= clsQueryString.QueryStringEncode("Id=1&name=Brijesh");
Decode
Query
string and
Get Value
int
id
=
clsCheckDBNull.ConvertToInt(clsQueryString.GetValueFromQueryString(Data,
"Id"));
string
Name = clsQueryString.GetValueFromQueryString(Data,
"Name")
Comments
Post a Comment