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)
{
}
谢谢。
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我将一个 div 与周围的图像包裹在一起,以强制它获取背景图像:
I'd wrap a div with the image around it to force it to take that background image:
我通过设置
UploaderStyle="Traditional"
解决了这个问题。不知道如何,但它有效。I have solved this by setting the
UploaderStyle="Traditional"
. Don't know how but it works.