What is DPI of a Image? DPI means dots per inch. how to get DPI of a Image when we upload file?
System.IO.MemoryStream mm = new System.IO.MemoryStream();
mm.Write(FileUpload1.FileBytes, 0, FileUpload1.FileBytes.Length);
System.Drawing.Image img = System.Drawing.Image.FromStream(mm);
Response.Write("Horizondal Resolution :" + img.HorizontalResolution.ToString());
Response.Write("Veritcal Resolution :" + img.VerticalResolution.ToString());
Response.Write("Pixel Format :" + img.PixelFormat);
Response.Write("Physical Dimension Height:"+img.PhysicalDimension.Height.ToString());
Response.Write("Physical Dimension Width:"+ img.PhysicalDimension.Width.ToString());
img.Dispose();
mm.Dispose();
Output
Horizondal Resolution :89.9922
Veritcal Resolution :89.9922
Pixel Format :Format32bppArgb
Physical Dimension Height :1200
Physical Dimension Width :1600
Adsence750x90
Thursday, November 27, 2008
Wednesday, November 26, 2008
Multiple Sorting in DataTables in C# - code helper and examples
We can multiple sort DataTable using DataView
Example
DataTable dt=new DataTable;
Bind dt From DataBase
DataView dv=dt.DefaultView;
dv.Sort="Column1,Column2,Column3 DESC";
dt=dv.ToTable();
Example
DataTable dt=new DataTable;
Bind dt From DataBase
DataView dv=dt.DefaultView;
dv.Sort="Column1,Column2,Column3 DESC";
dt=dv.ToTable();
Globally Unique Identifier (GUID) in C# - Tips and Tricks
A GUID is a 128-bit integer (16 bytes). GUID is Globally Unique Identifier. programmers can use this key as unique Key
We can generate Guid using C#
Guid objGuid=Guid.NewGuid();
string uniqueID=objGuid.ToString();
We can generate Guid using C#
Guid objGuid=Guid.NewGuid();
string uniqueID=objGuid.ToString();
Tuesday, November 25, 2008
How to get size of a file using asp.net and C#
How to get size of a file using asp.net and C#?
here is the solution.
this function return the size of the file in MB
private double fileSize(FileUpload file)
{
long KB = file.FileBytes.LongLength / 1024;
double MB = (double)KB / 1024;
return MB;
}
here is the solution.
this function return the size of the file in MB
private double fileSize(FileUpload file)
{
long KB = file.FileBytes.LongLength / 1024;
double MB = (double)KB / 1024;
return MB;
}
Friday, November 14, 2008
How to create Random string with numbers using C#
am providing a function to get random numbers. this function returning RandomKey. programmers can use this key fro captcha creation.
public string RandomStringKeys()
{
string returnString = string.Empty;
string Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
char[] letterArray = Letters.ToCharArray();
char[] numberArray = numbers.ToCharArray();
Random objrandomNumber = new Random();
byte[] selection = Encoding.ASCII.GetBytes(objrandomNumber.Next(111111, 999999).ToString());
BitArray bArray = new BitArray(selection);
string binaryString = string.Empty;
int t = 0;
int f = 0;
for (int i = 0; i < bArray.Length; i++)
{
if (bArray[i])
{
binaryString += 1;
t++;
}
else
{
binaryString += 0;
f++;
}
}
char[] enCodeString = binaryString.Substring(objrandomNumber.Next(1, 8), objrandomNumber.Next(4, 8)).ToCharArray();
for (int i = 0; i < enCodeString.Length; i++)
{
if (enCodeString[i] == '1')
{
returnString += letterArray[objrandomNumber.Next(0, 51)];
}
else
{
returnString += numberArray[objrandomNumber.Next(0, 9)];
}
}
return returnString;
}
public string RandomStringKeys()
{
string returnString = string.Empty;
string Letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
string numbers = "0123456789";
char[] letterArray = Letters.ToCharArray();
char[] numberArray = numbers.ToCharArray();
Random objrandomNumber = new Random();
byte[] selection = Encoding.ASCII.GetBytes(objrandomNumber.Next(111111, 999999).ToString());
BitArray bArray = new BitArray(selection);
string binaryString = string.Empty;
int t = 0;
int f = 0;
for (int i = 0; i < bArray.Length; i++)
{
if (bArray[i])
{
binaryString += 1;
t++;
}
else
{
binaryString += 0;
f++;
}
}
char[] enCodeString = binaryString.Substring(objrandomNumber.Next(1, 8), objrandomNumber.Next(4, 8)).ToCharArray();
for (int i = 0; i < enCodeString.Length; i++)
{
if (enCodeString[i] == '1')
{
returnString += letterArray[objrandomNumber.Next(0, 51)];
}
else
{
returnString += numberArray[objrandomNumber.Next(0, 9)];
}
}
return returnString;
}
Password Encrypt in ASP.Net C# - SHA1 encription with sample code
The code sample can be used in web pages to encrypt a password.The GetEncryptedPassword converts the plain text input to cipher text, in cryptography terminologies. To our use, is the static FormsAuthentication.HashPasswordForStoringInConfigFile() function that takes the plainText and also the algorithm that should be used to encrypt the password.In this example we use the SHA1 algorithm. Technically, the SHA1 algorithm is a hash algorithm and hence returns only a hash of the plaintext. A hashing algorithm one whose input size is not-fixed, but output's size is fixed. this is one way Encryption. you cant decrypt this password
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class PasswordEncription
{
public PasswordEncription()
{
}
public static string GetEncriptedPassword(string plainText)
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(plainText, "SHA1");
}
}
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public class PasswordEncription
{
public PasswordEncription()
{
}
public static string GetEncriptedPassword(string plainText)
{
return FormsAuthentication.HashPasswordForStoringInConfigFile(plainText, "SHA1");
}
}
Thursday, November 13, 2008
Creating Search Engine with C# and ASP.NET using Yahoo API - Build your Own Search Service (BOSS)
how to create a search engine? i search about the topic in google.i cant get useful results. finally i foound YAHOO API for making ower own Search engine,that is BOSS (Build your Own Search Service) is Yahoo!'s open search web services platform. you can read more about this topic from Yahoo, Build your Own Search Engine. Yahoo provide SDK for search engine.you can download from yahoo developer.
This SDK includes code in the following languages:
* ColdFusion
* C#
* Flash/Flex (ActionScript)
* Java
* JavaScript
* Lua
* Perl
* PHP
* Python
* Ruby
* VB.NET
* Widgets (JavaScript + XML)
ASP.NET and C# programmers can easliy create Search Engine with Yahoo.ASP.dll file.
for Web search call Yahoo.API
sample C# code from Yahoo.API
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Yahoo.API;
using System.Xml;
using System.IO;
public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnWebSearch_Click(object sender, EventArgs e)
{
YahooSearchService yahoo = new YahooSearchService();
Yahoo.API.WebSearchResponse.ResultSet resultSet = yahoo.WebSearch("YahooExample", TextBox1.Text, "all",10, 11, "any", true, true, "en");
StringWriter sw = new StringWriter();
foreach (Yahoo.API.WebSearchResponse.ResultType result in resultSet.Result)
{
sw.WriteLine("Title: {0}", result.Title);
sw.WriteLine("Summary: {0}", result.Summary);
sw.WriteLine("URL: {0}", result.Url);
sw.WriteLine("============================================");
}
Response.Write(sw.ToString());
}
}
This SDK includes code in the following languages:
* ColdFusion
* C#
* Flash/Flex (ActionScript)
* Java
* JavaScript
* Lua
* Perl
* PHP
* Python
* Ruby
* VB.NET
* Widgets (JavaScript + XML)
ASP.NET and C# programmers can easliy create Search Engine with Yahoo.ASP.dll file.
for Web search call Yahoo.API
sample C# code from Yahoo.API
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Yahoo.API;
using System.Xml;
using System.IO;
public partial class Search : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnWebSearch_Click(object sender, EventArgs e)
{
YahooSearchService yahoo = new YahooSearchService();
Yahoo.API.WebSearchResponse.ResultSet resultSet = yahoo.WebSearch("YahooExample", TextBox1.Text, "all",10, 11, "any", true, true, "en");
StringWriter sw = new StringWriter();
foreach (Yahoo.API.WebSearchResponse.ResultType result in resultSet.Result)
{
sw.WriteLine("Title: {0}", result.Title);
sw.WriteLine("Summary: {0}", result.Summary);
sw.WriteLine("URL: {0}", result.Url);
sw.WriteLine("============================================");
}
Response.Write(sw.ToString());
}
}
Wednesday, November 12, 2008
DataList Control with pagination - using viewstate
How to bind DataList control in asp.net. this lesson only provide programming parts of DataList control.tomorrow i will post the HTML portion of this program. Not like GridView. it is simple to code.
C# ASP.NET CODER
public int PageCount
{
get
{
object o = this.ViewState["_PageCount"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
ViewState["_PageCount"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostback)
{
FillDataList(true);
}
else
{
FillDataList(false);
}
}
public void FillDataList(bool a)
{
if (a)
PageCount = 0;
lbtnNext.Enabled = true;
lbtnNext2.Enabled = true;
lbtnPrevious.Enabled = true;
lbtnPrevious2.Enabled = true;
string cmd = string.Empty;
cmd = string.Format("SELECT table_field1,table_field2,table_field3,table_field4 FROM table WHERE condition1 >'{0}' AND condition1 ='{1}' AND condition1 >'0'", DateTime.Now, Request.QueryString["sdd"]);
DataTable BTab = objDBHelper.GetReaderTable(cmd, 7);
if (BTab.Rows.Count > 0)
{
if (a)
PageCount = 0;
lbtnNext.Enabled = true;
lbtnNext2.Enabled = true;
lbtnPrevious.Enabled = true;
lbtnPrevious2.Enabled = true;
DataColumn newcol = new DataColumn("imagecol", typeof(object));
DataColumn newcolm = new DataColumn("clubNamecol", typeof(object));
DataColumn newcolm1 = new DataColumn("bookme", typeof(object));
DataColumn calCol = new DataColumn("viewcal", typeof(string));
DataColumn calCol2 = new DataColumn("view", typeof(string));
BTab.Columns.Add(newcol);
BTab.Columns.Add(newcolm);
BTab.Columns.Add(newcolm1);
BTab.Columns.Add(calCol);
BTab.Columns.Add(calCol2);
for (int i = 0; i < BTab.Rows.Count; i++)
{
BTab.Rows[i]["imagecol"] = "imagefile";
BTab.Rows[i]["clubNamecol"] = (object)objDBHelper.ExecuteScalar(string.Format("SELECT xx FROM table WHERE condition='{0}'", BTab.Rows[i][1].ToString()));
BTab.Rows[i]["bookme"] = string.Format("BCalendar.aspx?bid={0}&cid={1}", BTab.Rows[i][0].ToString(), BTab.Rows[i][1].ToString());
BTab.Rows[i]["viewcal"] = string.Format("ECalendar.aspx?cid={0}&bid={1}", BTab.Rows[i][1].ToString(), BTab.Rows[i][0].ToString());
BTab.Rows[i]["view"] = string.Format("ClubDetails.aspx?cid={0}&bid={1}", BTab.Rows[i][1].ToString(), BTab.Rows[i][0].ToString());
}
pgddata = new PagedDataSource();
pgddata.DataSource = BTab.DefaultView;
pgddata.AllowPaging = true;
pgddata.CurrentPageIndex = PageCount;
pgddata.PageSize = 5;
lbtnPrevious2.Visible = !pgddata.IsFirstPage;
lbtnPrevious.Visible = !pgddata.IsFirstPage;
lbtnNext2.Visible = !pgddata.IsLastPage;
lbtnNext.Visible = !pgddata.IsLastPage;
dlClubList.DataSource = pgddata;
dlClubList.DataBind();
dlClubList.Visible = true;
}
else
{
dlClubList.Visible = false;
lbtnNext.Visible = false;
lbtnNext2.Visible = false;
lbtnPrevious.Visible = false;
lbtnPrevious2.Visible = false;
Label1.Visible = true;
Label1.Text = "No Events found..Please search for another City";
LinkButton2.Visible = true;
}
}
C# ASP.NET CODER
public int PageCount
{
get
{
object o = this.ViewState["_PageCount"];
if (o == null)
return 0;
else
return (int)o;
}
set
{
ViewState["_PageCount"] = value;
}
}
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostback)
{
FillDataList(true);
}
else
{
FillDataList(false);
}
}
public void FillDataList(bool a)
{
if (a)
PageCount = 0;
lbtnNext.Enabled = true;
lbtnNext2.Enabled = true;
lbtnPrevious.Enabled = true;
lbtnPrevious2.Enabled = true;
string cmd = string.Empty;
cmd = string.Format("SELECT table_field1,table_field2,table_field3,table_field4 FROM table WHERE condition1 >'{0}' AND condition1 ='{1}' AND condition1 >'0'", DateTime.Now, Request.QueryString["sdd"]);
DataTable BTab = objDBHelper.GetReaderTable(cmd, 7);
if (BTab.Rows.Count > 0)
{
if (a)
PageCount = 0;
lbtnNext.Enabled = true;
lbtnNext2.Enabled = true;
lbtnPrevious.Enabled = true;
lbtnPrevious2.Enabled = true;
DataColumn newcol = new DataColumn("imagecol", typeof(object));
DataColumn newcolm = new DataColumn("clubNamecol", typeof(object));
DataColumn newcolm1 = new DataColumn("bookme", typeof(object));
DataColumn calCol = new DataColumn("viewcal", typeof(string));
DataColumn calCol2 = new DataColumn("view", typeof(string));
BTab.Columns.Add(newcol);
BTab.Columns.Add(newcolm);
BTab.Columns.Add(newcolm1);
BTab.Columns.Add(calCol);
BTab.Columns.Add(calCol2);
for (int i = 0; i < BTab.Rows.Count; i++)
{
BTab.Rows[i]["imagecol"] = "imagefile";
BTab.Rows[i]["clubNamecol"] = (object)objDBHelper.ExecuteScalar(string.Format("SELECT xx FROM table WHERE condition='{0}'", BTab.Rows[i][1].ToString()));
BTab.Rows[i]["bookme"] = string.Format("BCalendar.aspx?bid={0}&cid={1}", BTab.Rows[i][0].ToString(), BTab.Rows[i][1].ToString());
BTab.Rows[i]["viewcal"] = string.Format("ECalendar.aspx?cid={0}&bid={1}", BTab.Rows[i][1].ToString(), BTab.Rows[i][0].ToString());
BTab.Rows[i]["view"] = string.Format("ClubDetails.aspx?cid={0}&bid={1}", BTab.Rows[i][1].ToString(), BTab.Rows[i][0].ToString());
}
pgddata = new PagedDataSource();
pgddata.DataSource = BTab.DefaultView;
pgddata.AllowPaging = true;
pgddata.CurrentPageIndex = PageCount;
pgddata.PageSize = 5;
lbtnPrevious2.Visible = !pgddata.IsFirstPage;
lbtnPrevious.Visible = !pgddata.IsFirstPage;
lbtnNext2.Visible = !pgddata.IsLastPage;
lbtnNext.Visible = !pgddata.IsLastPage;
dlClubList.DataSource = pgddata;
dlClubList.DataBind();
dlClubList.Visible = true;
}
else
{
dlClubList.Visible = false;
lbtnNext.Visible = false;
lbtnNext2.Visible = false;
lbtnPrevious.Visible = false;
lbtnPrevious2.Visible = false;
Label1.Visible = true;
Label1.Text = "No Events found..Please search for another City";
LinkButton2.Visible = true;
}
}
Helps Authorize.Net Payment Integration
i can help you in Authorize.Net Payment Integration. i am providing a dll file for payment integration. if u did not satisfy on that file u can contact me for payment integration process and provide other help in C# ASP.NET programming. you can check my payment helper file for test purpose.
Subscribe to:
Posts (Atom)