Software Programs and Projects

This Software Programs and Projects include programing tips and technology using different languages like VC++,ASP,JSP C#.Net,PHP,VB.Net,JavaScript,ASP.NET .Software Programs and Projects blog mainly support to software programmers and provide help through the mail.

How To Create Thumnail in Asp.NET with C#.NET

//Return thumbnail callback
public bool ThumbnailCallback()
{
return true;
}


///For Image Thumbnail

fileUploadImage : FileUpload Control

m_strRealImagePath : Real Image Path

m_strThumbnailImagePath : Thumbnail Image Path

lblError1 : Label Control



private void MakeThumbnail(string strProductImageName)
{

System.Drawing.Image myThumbnail150;
System.Drawing.Image.GetThumbnailImageAbort myCallback = new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback);

if (fileUploadImage.PostedFile != null && fileUploadImage.PostedFile.ContentLength > 0)
{
//this code used to remove some symbols between image name and replace with space
string strFileName = fileUploadImage.PostedFile.FileName.Replace('%', ' ').Substring(fileUploadImage.PostedFile.FileName.LastIndexOf("\\") + 1);

string strExtention = System.IO.Path.GetExtension(strFileName);
string imgname1 = strProductImageName.ToString();
string imgname2 = imgname1.Replace('#', ' ').Substring(imgname1.LastIndexOf("\\") + 1);
string imgname3 = imgname2.Replace('@', ' ').Substring(imgname1.LastIndexOf("\\") + 1);
string imgname4 = imgname3.Replace(',', ' ').Substring(imgname1.LastIndexOf("\\") + 1);
string imgname5 = imgname4.Replace('&', ' ').Substring(imgname1.LastIndexOf("\\") + 1);

Finalimagename = imgname5.ToString() + strExtention.ToString();

string imgname = fileUploadImage.PostedFile.FileName.Substring(fileUploadImage.PostedFile.FileName.LastIndexOf("\\") + 1);

string sExtension = imgname.Substring(imgname.LastIndexOf(".") + 1);

///Check File Exists Or Not

if (File.Exists(m_strRealImagePath + Finalimagename))
{
File.Delete(m_strRealImagePath + Finalimagename);
}

//this code is used to check image extension

if (sExtension.ToLower() == "jpg" || sExtension.ToLower() == "gif" || sExtension.ToLower() == "bmp" || sExtension.ToLower() == "jpeg")
{
if (!File.Exists(m_strRealImagePath + Finalimagename))
{
fileUploadImage.PostedFile.SaveAs(ResolveUrl(m_strRealImagePath + Finalimagename));

System.Drawing.Image imagesize = System.Drawing.Image.FromFile(ResolveUrl(m_strRealImagePath + Finalimagename));
Bitmap bitmapNew = new Bitmap(imagesize);
if (imagesize.Width < imagesize.Height)
{
myThumbnail150 = bitmapNew.GetThumbnailImage(150 * imagesize.Width / imagesize.Height, 150, myCallback, IntPtr.Zero);
}
else
{ myThumbnail150 = bitmapNew.GetThumbnailImage(150, imagesize.Height * 150 / imagesize.Width, myCallback, IntPtr.Zero);
}

//Save image in TumbnailImage folder

if (File.Exists(m_strThumbnailImagePath + Finalimagename))
{
File.Delete(m_strThumbnailImagePath + Finalimagename);
}
myThumbnail150.Save(ResolveUrl(m_strThumbnailImagePath) + Finalimagename, System.Drawing.Imaging.ImageFormat.Jpeg);
lblError1.Text = "Successfully uploaded";
imgProductImage.Visible = true;
m_strProductThumbnailImagePath = "~/UserData/ThumbnailImage/"+ Finalimagename;; m_strProductRealImagePath = "~/UserData/RealImage/"+ Finalimagename;
string imgDisplayName = m_strProductThumbnailImagePath;
imgProductImage.ImageUrl = imgDisplayName;
}
}
else
{
lblError1.Visible = true; lblError1.Text = "Check image extension";
}
}
} tag:-How To create thumbnail in asp.net with c#.net,

In PHP three types of strings are using single quoted,double quoted,heredoc



A string literal can be specified in four different ways:

  • single quoted
  • double quoted
  • heredoc


Single quoted

The simplest way to specify a string is to enclose it in single quotes (the character ').

echo 'this is a simple string'; echo 'You can also have embedded newlines in strings this way as it is okay to do'; // Outputs: Arnold once said: "I'll be back" echo 'Arnold once said: "I\'ll be back"';


<?php
echo 'this is a simple string';
echo 'You can also have embedded newlines in strings this way as it is okay to do';
// Outputs: Arnold once said: "I'll be back" echo 'Arnold once said: "I\'ll be back"';
?>




heredoc



<?php
echo <<<EOT My name is "$name".
I am printing some EOT;?>


A third way to delimit strings is the heredoc syntax: <<<. After this operator, an identifier is provided, then a newline. The string itself follows, and then the same identifier again to close the quotation. The closing identifier must begin in the first column of the line. Also, the identifier must follow the same naming rules as any other label in PHP: it must contain only alphanumeric characters and underscores, and must start with a non-digit character or underscore
tag:-rDi

fferent types of strings in php - single quoted,double quote,heredoc

Data Types

Booleans
Integers
Floating point numbers
Strings


Variable Declaration

Variables are used for storing a values, like text strings, numbers or arrays.
When a variable is set it can be used over and over again in your script
All variables in PHP start with a $ sign symbol.

The correct way of setting a variable in PHP:

Example :

$txt = "Hello World!";
$number = 16;




tags:-Variable declaration in PHP

Syntax

PHP supports singleline and multipleline comments

//This is a comment
/* This is a comment block */
#This is a comment


tags:-PHP supports singleline and multipleline comments

Each code line in PHP must end with a semicolon. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".


print command


<html>
<body>
<?php print"Helloworld" ?>
</body>
</html>

PHP supports print and echo commands for printing text in a web browser,

Each code line in PHP must end with a semicolon. There are two basic statements to output text with PHP: echo and print. In the example above we have used the echo statement to output the text "Hello World".


echo command

<html>
<body>
<?php print"Helloworld" ?>
</body>
</html>

tag:- PHP : print and echo commands using for print text in a web server


Example "Hello World"

"

echo "Hello World";
?>

"

PHP is a powerful server-side scripting language for creating dynamic and interactive websites. PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP. PHP is perfectly suited for Web development and can be embedded directly into the HTML code. The PHP syntax is very similar to Perl and C. PHP is often used together with Apache (web server) on various operating systems.

PHP is a powerful tool for making dynamic and interactive Web pages.

PHP is the widely-used, free, and efficient alternative to competitors such as Microsoft's ASP.
In our PHP tutorial you will learn about PHP, and how to execute scripts on your server.

PHP code is executed on the server, and the plain HTML result is sent to the browser.


Basic PHP Syntax

A PHP scripting block always starts with .

A PHP scripting block can be placed anywhere in the document.


tag:-PHP Introduction, PHP Tutorial

//Checking Listbox item selected or not in C#.Net
//Selected ListBox Item Value and Text

if (this.listBoxExistingDestination.SelectedIndex != -1)
{
//Selected ListBox Item Value and Text
int iDestinationId = (int)this.listBoxExistingDestination.SelectedValue;
string strDestinationName=this.listBoxExistingDestination.Text;
}
else
{
//Unselect
}

the same code using for Dropdownlist control in C#.NET windows based application

tag:-Check if Item selected in Listbox : C#.Net

Related Posts

#region Function to check if a value is numeric

public static bool IsNumeric(string strValue)
{
int iCount = 0;
int iValue;
if (string.IsNullOrEmpty(strValue))
{
iCount = 0;
}
else
{
foreach (char cCharacter in strValue)
{
if (int.TryParse(Convert.ToString(cCharacter), out iValue))
{
iCount += 1;
}
else
{
iCount = 0;
return false;
}
}
}
if (iCount > 0)
return true;
else
return false;
}
#endregion

tag-:Check numeric in C#.NET

How can clear listbox control selection using C#.Net

#region Clear Listbox Control

private void ClearListBoxControlSelection(ListBox listBoxItem)
{
for (int iIndex = 0; iIndex < listBoxItem.Items.Count; iIndex++)
{
listBoxItem.SetSelected(iIndex, false);
}
}

#endregion


tags:- How can clear listbox controls selection in C#.Net

In everyday life when we deal with time, we speak in seconds, minutes, hours, days, weeks, months, years, decades, centuries, etc.... you get the idea. When PHP deals with time it uses only one measurement, seconds. More specifically it measures time in seconds since January 1, 1970. Once we know how time works in PHP, it becomes easier to add, subtract, and calculate time. Below is a quick guide:

Time in Seconds
1 Minute: 60 seconds
1 Hour: 3,600 seconds
1 Day: 86,400 seconds
1 Week: 604,800 seconds
4 Weeks: 2,419,200 seconds
1 Year: 31,536,000 seconds
1 Decade: 315,360,000 seconds

Now let's put this into practice. Let's say for example you wanted to set a cookie in a user's browser to expire in one year. The way we would calculate this is by adding one year, or 31,536,000 seconds to the current date before setting the cookie:

$Year = 31536000 + time() ;
Perhaps you want to find out what calendar day occurs in a set period of time. This is what is done in pregnancy calendars. In this example we will find the calendar date that occurs in exactly 2 weeks (1209600 seconds) time. $twoweeks = 1209600 + time() ;
echo date("M-d-Y", $twoweeks) ;