Showing posts with label javascript. Show all posts
Showing posts with label javascript. Show all posts

Tuesday, August 17, 2010

Asynchronous File Upload in Asp.net using C# jquery Uploadify

Hello Readers,
You might have a need for uploading files asynchronously in asp.net using c# with jquery.
here i will give u the best tutorial to do this.
You will need to download the jquery pluggin this.download this pluggin from here.
http://www.uploadify.com/download/
after u download this file extract this folder and rename it to uploadify and put it in the root folder of ur project.
Now crate new aspx page from which we will upload file. name it ImageUploader.aspx(you can give any name)
insert the following code in ur header part of ur file.


    

    

    

//reference of css file of uploadify, you will find this in the folder  uploadify
and then in the body of ur page insert the following code...

   
Now let's create the handler to receive the httpPostedData.
Add Generic Handler to ur project(Right click on project from solution explorer and then click on add new item.from the given option select Generic Handler). Name it Uploader.ashx
The code for the handler is as below.
using System;
using System.Web;
using System.Web.SessionState;

public class Uploader : IHttpHandler, IRequiresSessionState
{
    
    public void ProcessRequest (HttpContext context) {
        try
        {
            HttpPostedFile file = context.Request.Files["Filedata"];
            int id = (Int32.Parse(context.Request["id"]));//here we are accessing the passed values from the javascript
            string filename = id.ToString() + file.FileName;
            string filepath = HttpContext.Current.Server.MapPath("~").ToString() + "\\Avatar\\"+filename ;
            file.SaveAs(filepath);
            //your asp.net logic to save file path in database
            context.Response.Write("1");
        }
        catch (Exception ex)
        {
            context.Response.Write("0");
        }
    }

    public bool IsReusable {
        get {
            return false;
        }
    }

} 
It's done just run ur imageupload.aspx page and click on browse button to upload the file.
if u face any problem feel free to contact me on
info@amitech.co
Amit Panchal
www.amitech.co

Wednesday, July 28, 2010

Modification to flot chart component

Hello friends,
flot is very good and flexible component to use for graphs and charts.
you can download the flot component from here.
this flot component provides bar chart and line chart.
line chart works fine but in bar chat you can display only two series of data.because it has only two option to align the data. left and center. if you have some more data series then it will overlap the existing data series.
so i have added one more option to alignment and that is right alignment.

if u want to display four data series then left right and center is not a good option to alignment,
so u can pass first,second,third and fourth as an alignment argument.

to get the modified version of click here
if you have any doubts feel free to email me at info@amitech.co
Amit Panchal
http://amitech.co

Amitech

Hell0 Friends,
i know you are stuck with some serious problems and that's why you are here. So friends i m putting all the solved problems(with solution) that i have faced in my life (technical problems) on this blog.
In case you can not find the proper solutions, feel free to mail me at info@amitech.co
Amit Panchal