Click here to Skip to main content
15,892,643 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

this is my ASPX page

ASP.NET
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <table border="1">
            <tr>
                <td>
                    <input type="file" name="name" value="" />
                </td>
                <td>
                    <input type="button" name="name" value="Upload" />
                </td>
            </tr>
        </table>
    </form>
</body>
</html>

C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Services;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    [WebMethod]
    public static string Uploadfile()
    {
        //if(file uploaded successfully)
            return "File Uploaded";
        //else
            return "error";
    }
}


i want to upload single file by jQuery, but can't do it.
plz help me!!!
Posted
Comments
P_Dash 31-Jan-13 5:02am    
Where is the Upload Logic ?
Do you want to Upload Asynchronously ??
shajarian_lover 31-Jan-13 5:04am    
i want to send the selected file to asp code behind, then save it by Uploadfile()
function
P_Dash 31-Jan-13 5:20am    
Well then I'd Suggest you to use Ajax Async File Upload Control.
So if you don't have any problem use this.

1 solution

You might find this[^] question provides a decent answer. The big question, though, is which browsers you need to support. If you have to support old browsers (i.e. IE7, etc), then you need to consider using IFrames to support this.
 
Share this answer
 
Comments
Ankur\m/ 31-Jan-13 5:04am    
:thumbsup:
Nandakishore G N 31-Jan-13 5:22am    
superb answer.my 5..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900