modalpopupextender中的AsyncFileUpload参数错误无效

时间:2010-07-09 10:17:48

标签: asp.net javascript ajax modalpopupextender asyncfileupload

页面加载时收到此错误:参数无效。 在这一行:

a._innerTB.style.width=a._inputFile.offsetWidth-107+"px"

如果我删除此属性UploaderStyle =“Modern”,我没有错误。此外,如果我使用没有ModalPopupExtender的控件,我也没有错误。

您是否知道如何使用酷炫的现代风格解决此问题?

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Test.aspx.cs" Inherits="Test" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<!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">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajax:ToolkitScriptManager>
    <div>
        <asp:Button ID="btnOpen" runat="server" Text="Open" />
        <ajax:ModalPopupExtender ID="pnlUpload_mpe" runat="server" DynamicServicePath=""
            Enabled="True" TargetControlID="btnOpen" PopupControlID="pnlUpload" BackgroundCssClass="modalBackground">
        </ajax:ModalPopupExtender>
        <%--ModalPopup file upload--%>
        <asp:Panel ID="pnlUpload" runat="server">
            <script type="text/javascript" language="javascript">

                function uploadComplete(sender, args) {
                    var filename = args.get_fileName();
                    var contentType = args.get_contentType();
                    var text = "Size of " + filename + " is " + args.get_length() + " bytes";
                    if (contentType.length > 0) {
                        text += " and content type is '" + contentType + "'.";
                    }
                    $get("<%=lblStatus.ClientID %>").innerText = text;
                }

                function uploadError(sender, args) {
                    $get("<%=lblStatus.ClientID %>").innerText = args.get_fileName(), "<span style='color:red;'>" + args.get_errorMessage() + "</span>";
                }

                function startUpload(sender, args) {
                    $get("<%=lblStatus.ClientID %>").innerText = 'Uploading Started.';
                }

            </script>
            <br />
            <br />
            <ajax:AsyncFileUpload ID="AsyncFu" runat="server" Width="300" UploaderStyle="Modern"
                OnClientUploadError="uploadError" OnClientUploadStarted="startUpload" OnClientUploadComplete="uploadComplete"
                ThrobberID="ibWait" OnUploadedComplete="AsyncFu_UploadedComplete" />
            <asp:ImageButton ID="ibWait" runat="server" ImageUrl="~/images/Wait.gif" AlternateText="loading" />
            <br />
            <br />
            <asp:Label ID="lblStatus" runat="server" Text="Label"></asp:Label>
            <br />
            <br />
            <asp:Button ID="btnOk" runat="server" Text="Ok" Width="64" />
            <br />
            <br />
        </asp:Panel>
    </div>
    </form>
</body>
</html>

代码背后:

protected void AsyncFu_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
{

}

感谢。

2 个答案:

答案 0 :(得分:0)

我用它周围的图像包裹一个div来强制它拍摄背景图像:

<div style="background:url(/WebResource.axd?d=4aicOdyPTcU1uCDL6TJaMogi8jp7nEFhFdMy-zDDeZJHfZibfnO3WL4-FoFVjZ0IkhjgO6JOuY3LFuoQynhgqy49bl_CUdY4W5bofG0AYNxySS0gZV5Juyg6wn8MYlfPPLaCzhYwPDsFiLP25YErWX8X0GHvUyt9wnznVOgENUo1&amp;t=634092594280000000) no-repeat 100% 1px; height:24px; margin:0px;width:300px;">
            <ajax:AsyncFileUpload ID="AsyncFu" runat="server" Width="300" UploaderStyle="Modern"
                OnClientUploadError="uploadError" OnClientUploadStarted="startUpload" OnClientUploadComplete="uploadComplete"
                ThrobberID="ibWait" OnUploadedComplete="AsyncFu_UploadedComplete"/>
</div>

答案 1 :(得分:0)

我通过设置UploaderStyle="Traditional"解决了这个问题。不知道它是如何运作的。