2

页面加载时我收到此错误:参数无效。在这条线上:

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)
{

}

谢谢。

4

2 回答 2

0

我已经通过设置解决了这个问题UploaderStyle="Traditional"。不知道如何,但它的工作原理。

于 2012-09-24T23:23:57.247 回答
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>
于 2012-06-23T23:14:58.033 回答