asp.net使用jQuery Uploadify上传附件示例

发布时间:2022-04-16 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了asp.net使用jQuery Uploadify上传附件示例脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。

Uploadify是jquery的一个上传插件,实现的效果非常不错,带进度显示。Uploadify官方网址:http://www.uploadify.com/,在MVC中使用的方法可以参考 jQuery Uploadify在ASP.NET MVC3中的使用 和 Asp.net Mvc中使用uploadify实现图片缩放保存。

本文是一个简单的介绍Demo,主要是动态传递参数方法:通过formdata 向处理程序传递额外的表单数据:

复制代码 代码如下:

<!DOCTYPE htML PubLIC "-//W3C//DTD XHTML 1.0 TransITional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html XMlns="http://www.w3.org/1999/xhtml">
<head runat="server">
&nbsp;   <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': '浏览',
                'buttonimg': 'uploadify/browse.jpg',
                'folder': '../uploaDFile',
                'fileDesc': '附件',
                'onUploadStart': function (event, data) { //this is where you will 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 through post , make sure it is rendered in your page( //i.e.not concealed by a multiview control e.t.c)
             );
                }

            });
        });
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <asp:FileUpload ID="FileUpload1" runat="server" />
    <asp:DropDownList ID="ddlsecInfo" runat="server">
        <asp:ListItem Text="公开" Value="1"> </asp:ListItem>
        <asp:ListItem Text="普通" Value="2"> </asp:ListItem>
        <asp:ListItem Text="机密" Value="3"> </asp:ListItem>
    </asp:DropDownList>
    <a href="javascript: $('#<%=FileUpload1.ClientID %>').uploadify('upload','*')">上传</a>
    <a href="javascript:$('#<%=FileUpload1.ClientID %>').uploadify('cancel','*')">取消上传</a>
    </form>
</body>
</html>

脚本宝典总结

以上是脚本宝典为你收集整理的asp.net使用jQuery Uploadify上传附件示例全部内容,希望文章能够帮你解决asp.net使用jQuery Uploadify上传附件示例所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签: