protected void btn_upload_Click(object sender, EventArgs e) { imageflag = 1; if (!FileUpload_image.HasFile) { Alert.Show("No file for uploading"); return; } if (FileUpload_image.HasFile) { //string imagetype = FileUpload_image.PostedFile.ContentType; string[] acceptedTypes = new string[] { "image/bmp", "image/jpeg", "image/tiff", "image/gif", "image/png" }; if (!acceptedTypes.Contains(FileUpload_image.PostedFile.ContentType)) { Alert.Show("This is not image file"); return; } Bitmap image = ResizeImage(FileUpload_image.PostedFile.InputStream, 84, 118); string imagename = Guid.NewGuid().ToString(); image.Save(Server.MapPath("~/Pictures/") + imagename + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg); Img_Employee.ImageUrl = "~/Pictures/" + imagename + ".jpg"; image_path = "~/Pictures/" + imagename + ".jpg"; } } private Bitmap ResizeImage(Stream streamImage, int maxWidth, int maxHeight) { Bitmap originalImage = new Bitmap(streamImage); int newWidth = originalImage.Width; int newHeight = originalImage.Height; double aspectRatio = (double)originalImage.Width / (double)originalImage.Height; if (aspectRatio <= 1 && originalImage.Width > maxWidth) { newWidth = maxWidth; newHeight = (int)Math.Round(newWidth / aspectRatio); } else if (aspectRatio > 1 && originalImage.Height > maxHeight) { newHeight = maxHeight; newWidth = (int)Math.Round(newHeight * aspectRatio); } return new Bitmap(originalImage, newWidth, newHeight); }
Thursday, May 31, 2012
how to upload photo or picture in asp.net using c#
how to Upload Image or file on FTP in Asp.net using c#
copy the below code in your .cs file.
public void ftpfile(string ftpfilepath) { string ftphost = "your domain name "; //here correct hostname or IP of the ftp server to be given string ftpfullpath = "ftp://" + ftphost + ftpfilepath; FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath); ftp.Credentials = new NetworkCredential("your Domain", "Password"); //userid and password for the ftp server to given ftp.KeepAlive = true; ftp.UseBinary = true; ftp.Method = WebRequestMethods.Ftp.UploadFile; // Resize Image is function to resize the image System.Drawing.Image img1 = ResizeImage(FileUpload1.PostedFile.InputStream, 84, 118); // Convert the image into bytes Array; byte[] buffer = ImageToByte(img1); // Send the image file in form of bytes Stream ftpstream = ftp.GetRequestStream(); ftpstream.Write(buffer, 0, buffer.Length); ftpstream.Close(); }
Saturday, May 26, 2012
how to disable right click using jquery
how to generate image button dynamically in asp.net using c#
protected void Page_Load(object sender, EventArgs e) { ImageButton imgBtn; imgBtn = new ImageButton(); imgBtn.Attributes.Add("onclick", "javascript:return false;"); imgBtn.ImageUrl = "~/sample.jpg"; imgBtn.ID = "img_Tooltip"; imgBtn.ToolTip = "www.web-healer.blogspot.com"; imgBtn.CssClass = "img_tooltip_Style"; imgBtn.Height = 50; imgBtn.Width = 100; form1.Controls.Add(imgBtn); }
Thursday, May 24, 2012
how to add text to image in asp.net using c#
using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; using System.Drawing.Text; using System; public partial class About : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string inputImage = @"E:\color.jpg"; string outputImageFilePath = @"E:\Resultimage.jpg"; string textToDisplayOnImage = "www.webhealer.blogspot.com/"; Bitmap imageInBitMap = new Bitmap(inputImage); Graphics imageGraphics = Graphics.FromImage(imageInBitMap); //Set the alignment based on the coordinates StringFormat formatAssignment= new StringFormat(); formatAssignment.Alignment = StringAlignment.Near; //Here we are going to assign the font color Color assignColorToString = System.Drawing.ColorTranslator.FromHtml("#000000"); //Assigning font size, font family, position of the text to display and others. imageGraphics.DrawString(textToDisplayOnImage, new Font("Times new Roman", 8, FontStyle.Bold), new SolidBrush(assignColorToString), new Point(100, 150), formatAssignment); //saving in the computer imageInBitMap.Save(outputImageFilePath); } }
Monday, May 21, 2012
how to use span tag on a web page using html
span tag is used to provide an additional structure to an html document. It is used to group and apply style sheet to inline elements of a web page. it can be used to gave characteristics to specific part of other elements.
below is the code example how to use spam tag.outputThis is a paragraph this is a paragraph this is a paragraph
this is a paragraph
This is a paragraph this is a paragraph this is a paragraph
this is a paragraph
how to use div tag on a web page using html
div tag is normally used to define a section in an html document or in a web page div tag is a pair tag and must be used a closing tag in order to complete the tag
outputthis is div tag
how to use font tag in html
this text is with Verdana font this text is with arial font this text is with helvitica font this text is with impact fontthis text is with Verdana font
this text is with arial font
this text is with helvitica font
this text is with impact font
how to use different format text in html
here is the code to make text bold
in order to make text boldoutput:
in order to make text bold
here is the code to make text italic
in order to make text boldoutput:
in order to make text Italic
here is the code to make text underline
in order to make text underlineoutput:
in order to make text underline
here is the code to make text super script
in order to make text Super Scriptoutput:
in order to make text Super Script
here is the code to make text Sub script
in order to make text Sub Scriptoutput:
in order to make text Super Script
how to use horizontal line tag in html
how to use line break tag using html
Line breaks are used to decide where the text will break on a line or continue to the end of the window. it can be used to move the control to the next new line.
see the below code and example syntax of code of line break tag
this is line one<br> this is line tow<br> this is line three<br>
how to use paragraph tag in html
paragraph tag are used in a document to add text in such a way that it will automatically adjust the end of line to suit the window size of the browser.
see the below example of paragraph tag
this is paragraph tag
how to use heading tag in html
headings are very important part of any web page. it is used to display different type of heading in HTML document
heading tag is a pair tag, pair tag means every opening tag must have a closing tag.
see the below code of heading tags. it has 6 types as follows
Outputthis is heading type 1
this is heading type 2
this is heading type 3
this is heading type 4
this is heading type 5
this is heading type 6
this is heading type 1
this is heading type 2
this is heading type 3
this is heading type 4
this is heading type 5
this is heading type 6
Thursday, May 17, 2012
how to create basic html page
my first page this is body of the page. web-healer.blogspot.com
Sunday, May 13, 2012
How to generate random numbers in asp.net using c#
Random rand = new Random((int)DateTime.Now.Ticks); int numIterations = 0; numIterations= rand.Next(1, 100); Response.Write(numIterations.ToString());