Friday, February 22, 2008

Create a simple Movie player For html site

< object type="video/x-ms-wmv"
data="YourMovie.wmv" width="320" height="260" >
<param name="src" value="YourMovie.wmv" />
<param name="autostart" value="true" />
<param name="controller" value="true" />

</object >

Thursday, February 21, 2008

Creating mail Class Using C# dotnet (2005VS)

public bool SendEmailUserRegistration(string strEmailFrom, string strEmailTo, string strMailSubject ,string strMailBody,string username,string password)
{
try
{
SmtpClient smtp = new SmtpClient(System.Configuration.ConfigurationSettings.AppSettings["SmtpServer"]);
smtp.Host = "127.0.0.1";
smtp.Port = Convert.ToInt32(System.Configuration.ConfigurationSettings.AppSettings["Port"]);

MailMessage message = new MailMessage(strEmailFrom, strEmailTo);
message.From = new MailAddress(strEmailFrom,"Admin");
message.Subject = System.Configuration.ConfigurationSettings.AppSettings["MessageSubjectUserCreation"].ToString();
message.IsBodyHtml = true;
message.Body = System.Configuration.ConfigurationSettings.AppSettings["MessageBodyUserCreation"].ToString() +"User Name: " + username+ "
" +"Password: "+ password;

//smtp.Send(strEmailFrom, "Name@Company.com", "test subject", strMailBody);
smtp.Send(message);
return true;
}
catch (Exception ex)
{
return false;
}
}

Wednesday, February 20, 2008

Change the maximum file upload size supported by ASP.NET

Indicates the maximum file upload size supported by ASP.NET. This limit can be used to prevent denial of service attacks caused by users posting large files to the server. The size specified is in kilobytes. The default is 4096 KB (4 MB).

Add this code to webconfig
==========================

system.web
httpRuntime maxRequestLength="2097151" executionTimeout="3600"
system.web

Monday, February 18, 2008

Create a dataset Using Specified colum name and to data table C# code

DataSet dsTemp = new DataSet();
//dsTemp = null;
int recqty = 0;

DataTable dtAddNewItems = new DataTable();
DataColumn[] columns = {
new DataColumn("Product_No"),
new DataColumn("Qty_Received"),
new DataColumn("Certificates"),
new DataColumn("CertificateContentType"),
new DataColumn("TransportDamage"),
new DataColumn("PurrchaseQty"),
new DataColumn("Lot_No"),
new DataColumn("Qty_Returned")

};

dtAddNewItems.Columns.AddRange(columns);
dsTemp.Tables.Add(dtAddNewItems);

Find a list Box is Checked (has a list count) using java script

function listBoxisChecked(s,e)
{
var Lstbox=document.getElementById('ctl00_ContentPlaceHolder2_lbxAssignedGroup');

if(Lstbox.options.length == 0)
{
e.IsValid = false;

return;
}
e.IsValid = true;

}

Get Print screen Popup using javascript

html
head
script type="text/javascript">
windows.print();
/script
/head
/html

Friday, February 8, 2008

Random password Creator C# code

public static string CreateRandomPassword(int PasswordLength)
{
string _allowedChars = "abcdefghijkmnopqrstuvwxyzABCDEFGH­JKLMNOPQRSTUVWXYZ0123456789!@$?";
Random randNum = new Random();
char[] chars = new char[PasswordLength];
int allowedCharCount = _allowedChars.Length;
for (int i = 0; i < PasswordLength; i++)
{
chars[i] = _allowedChars[(int)((_allowedChars.Length) * randNum.NextDouble())];
}
return new string(chars);
}