asp.net use jquery uploadify Upload Attachment example _ Practical Tips

Source: Internet
Author: User

Uploadify is a jquery upload plugin, the implementation of the effect is very good, with progress display. Uploadify Official website: http://www.uploadify.com/, the method used in MVC can refer to the use of JQuery uploadify in asp.net MVC3 and asp.net Use uploadify in MVC to implement picture scaling saves.

This article is a simple introduction demo, mainly dynamic transfer parameter method: Through the formdata to the handler to pass additional form data:

Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title></title>
<link href= "Uploadify/uploadify.css" type= "Text/css" rel= "Stylesheet"/>
<script type= "Text/javascript" src= "Uploadify/jquery-1.7.2.min.js" ></script>
<script type= "Text/javascript" src= "Uploadify/swfobject.js" ></script>
<script type= "Text/javascript" src= "Uploadify/jquery.uploadify.min.js" ></script>
<script type= "Text/javascript" >

$ (function () {
var taskId = "<%= taskId%>";
var ActivityID = "<%= ActivityID%>";
var userId = "<%= getcurrentloginuser (). ID%>";

$ ("#<%=fileupload1.clientid%>"). Uploadify (
{
' swf ': ' uploadify/uploadify.swf ',
' Uploader ': ' uploadhandler.aspx ',
' Auto ': false,
' method ': ' Post ',
' Multi ': true,
' ButtonText ': ' Browse ',
' buttonimg ': ' Uploadify/browse.jpg ',
' Folder ': '. /uploadfile ',
' Filedesc ': ' Attachment ',
' Onuploadstart ': function (event, data) {//this is where your'll send the form//data, but remember to get if from post In the. ashx file, by Contex. request["Gallaryid"]
$ ("#<%=fileupload1.clientid%>"). Uploadify (' Settings ', ' FormData ',
{' taskId ': taskId, ' ActivityID ': ActivityID, ' userId ': userId, ' Secinfo ': $ ("#<%=ddlsecinfo.clientid%>"). Val ()} Note Hiddengallaryid would//have the Gallaryid which im sending post, make through it are sure in rendered-page (/ /i.e.not concealed by a MultiView control e.t.c)
);
}

});
});
</script>
<body>
<form id= "Form1" runat= "Server" >
<asp:fileupload id= "FileUpload1" runat= "Server"/>
<asp:dropdownlist id= "Ddlsecinfo" runat= "Server" >
<asp:listitem text= "Public" value= "1" > </asp:ListItem>
<asp:listitem text= "Normal" value= "2" > </asp:ListItem>
<asp:listitem text= "Confidential" value= "3" > </asp:ListItem>
</asp:DropDownList>
<a href= "javascript: $ (' #<%=fileupload1.clientid%> '). Uploadify (' upload ', ' * ')" > Upload </a>
<a href= "javascript:$ (' #<%=fileupload1.clientid%> '). Uploadify (' Cancel ', ' * ')" > Cancel upload </a>
</form>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.