Friday, March 23, 2012

Show Large Image on MouseOver using JavaScript in asp.net

Generally when a website displays images on the page, the use may think to see big image without clicking on the actual image. To achieve this the following example may help you ....





Sunday, March 18, 2012

HtmlEditorExtender Ajax Control - asp.net

with the help of ajax htmleditor extender we can send messages like office word with different styles.. as shown below...




Saturday, March 10, 2012

City State Country From public IP Address ASP.NET

To get City, State, Country, details From public IP Address first we need to get PublicIp as mentioned this article

clients public ip address in asp.net (C#)

Next to get the details free registration for your website is required to get API key.

If you don’t have an API key yet, just go to here and register for your free API key. You will need this API key to be able to use our newer APIs.

clients public ip address in asp.net (C#)

Generally web developers need clients public ip address to store the ip in the DataBase when loging the client for some perticular security reasons. So here is the simple way to get Clients public IP address...

        WebClient webClient = new WebClient();
        string ipAddress = webClient.DownloadString("http://myip.ozymo.com/");


For the WebClient we need the namespace as using System.Net;

I hope this is the simple way to get the IP.

save / retrieve image in SQL SERVER database (C#)


I think storing images in Database can save a developer lots of time and can ease his life while dealing with visuals, either creating a local application or a web application. Think of storing your images of a certain web application in a database instead in a directory exits somewhere in a cloud which one-a bit headache and second-completely transparent with respects to its location. So, here we are, I am going to create here a local application through which we can insert and retrieve an image using c# from a sql server 2008 database.

 First of all you need to create database to store and retrieve images in the form of bytes as follows....

 imageid, imagename, image are the columns for the table images

here we need 3 buttons, 1 file dialog control one image control to display image and store image in DB.

Declare 4 global variables as stated...

        string imageid;
        string imagename;
        SqlDataAdapter da;
        DataSet ds;

In btnSelect_Click to select Image

            try
            {
                FileDialog fldlg = new OpenFileDialog();

                fldlg.InitialDirectory = @":D\"; 

                fldlg.Filter = "Image File (*.jpg;*.bmp;*.gif)|*.jpg;*.bmp;*.gif";   // To select OnlyImages            
                if (fldlg.ShowDialog() == DialogResult.OK)
                {
                    imagename = fldlg.FileName;
                    Bitmap newimg = new Bitmap(imagename);
                    pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
                    pictureBox1.Image = (Image)newimg;
                }
                fldlg = null;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString());
            }

In brnsave _Click event

Resize image when uploading (C#)

This is the way you need to reduce the image size....
By default i reduced the size of the image to 200 X 400
U can chang eit
 
 
private Bitmap ResizeImage(Stream streamImage)
{ 
    int maxWidth = 200;
    int maxHeight = 400;
Bitmap originalImage = new Bitmap(streamImage);
    int newWidth = originalImage.Width;
    int newHeight = originalImage.Height;
    double aspectRatio =  
(double)originalImage.Width / (double)originalImage.Height;

Crop Image in ASP.NET using JCrop, JQuery (in masterpage)

This is to inform you all that jcrop  had a problem to crop in master pages but works good in aspx pages.
So i had a solution to use jcrop in masterpages....

Download working demo from the following link Click Here

After downloading open in ur vs and run it u will see an image and select a particular size as shown below.


Upload Multiple Images With Progress Bar Using Uploadify in asp.net

The jQuery Uploadify website gives us ready example for PHP, but leaves the new guies to C# or VB clueless on how to implement the same in .NET.

So, here I am presenting you with example of C#.NET implementation (upload.ashx) for the jQuery Uploadify plugin from a reference as shown below in master page to upload the file and crop it using jcrop with single Image in the next post :

Getting Sessions in HttpHandlers (ASHX files)

To read or assign session values in *.ashx files just add IRequiresSessionState or IReadOnlySessionState
as follows.....


<% @ webhandler language="C#" class="ShowImage" %>

using System;
using System.Web;
using System.Web.SessionState;