modalpopupextender 内的 AsyncFileUpload 出现无效参数错误

发布于 2024-09-09 06:09:53 字数 3402 浏览 9 评论 0原文

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

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

}

谢谢。

I receive this error when the page loads: Invalid argument.
On this line:

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

If I remove this attribute UploaderStyle="Modern", I don’t have the error. Also, if I use the control without the ModalPopupExtender, I don’t have the error as well.

Do you have an idea how can I resolve this problem with the cool Modern style?

<%@ 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>

Code behind:

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

}

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

握住我的手 2024-09-16 06:09:53

我将一个 div 与周围的图像包裹在一起,以强制它获取背景图像:

<div style="background:url(/WebResource.axd?d=4aicOdyPTcU1uCDL6TJaMogi8jp7nEFhFdMy-zDDeZJHfZibfnO3WL4-FoFVjZ0IkhjgO6JOuY3LFuoQynhgqy49bl_CUdY4W5bofG0AYNxySS0gZV5Juyg6wn8MYlfPPLaCzhYwPDsFiLP25YErWX8X0GHvUyt9wnznVOgENUo1&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>

I'd wrap a div with the image around it to force it to take that background image:

<div style="background:url(/WebResource.axd?d=4aicOdyPTcU1uCDL6TJaMogi8jp7nEFhFdMy-zDDeZJHfZibfnO3WL4-FoFVjZ0IkhjgO6JOuY3LFuoQynhgqy49bl_CUdY4W5bofG0AYNxySS0gZV5Juyg6wn8MYlfPPLaCzhYwPDsFiLP25YErWX8X0GHvUyt9wnznVOgENUo1&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>
攀登最高峰 2024-09-16 06:09:53

我通过设置 UploaderStyle="Traditional" 解决了这个问题。不知道如何,但它有效。

I have solved this by setting the UploaderStyle="Traditional". Don't know how but it works.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文