当组件位于不同选项卡中时,AsyncFileUpload 在 AjaxControlToolkit 中存在逻辑错误,因此未显示
我正在使用 AjaxControlToolkit 的 11 月版本,并且发现了一个逻辑错误,但我试图在周六之前找到解决此问题的最佳方法,以便该程序可以在 IE 上运行。
该问题仅在IE上有错误,在Firefox3.5上有效。
我的选项卡上有一个 AsyncFileUpload 组件,当该函数运行时,该组件似乎不可见,因此偏移宽度为零。
问题出在文件 AsyncFileUpload.pre.js
的函数 _app_onload
中,以及这一行: this._innerTB.style.width = (this._inputFile.offsetWidth - 107) + "px";
我不想从源代码编译它,但这可能最终是我的最佳选择,这样我就可以修复错误。
但是,这可能是我的解决办法: this._innerTB.style.width = ((this._inputFile.offsetWidth == 0) ? 200 : this._inputFile.offsetWidth) - 107) + "px";
但是,我不知道如果有更好的解决方案。
我可以在我的 javascript 类中编写一个新的原型函数,然后修复逻辑错误,这比重新编译要好。如果我在代码中修复它,那么每当我进行更新时,我都需要不断替换该行,直到它在代码库中得到修复。
但是,我试图弄清楚是否有一种方法可以让元素知道它刚刚变得可见,因为任何时候你需要知道元素的实际宽度,那么在它显示之前你无法真正设置它。我想不出一种方法来知道这一点,所以我倾向于做的是在第一次选择选项卡时修复选项卡上的元素,但是,对于通用库来说,这不是一个可能的解决方案。
主要问题的位置
因此,在发送有关此问题的错误报告之前,我很好奇是否有更好的方法来做到这一点,而不是在页面加载时完成它,并假设最小宽度可能是错误的。 <-- 问题位于此处
我正在使用以下代码来创建元素:
<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
OnClientUploadError="uploadError" OnClientUploadStarted="StartUpload"
OnClientUploadComplete="UploadComplete"
CompleteBackColor="Lime" UploaderStyle="Modern" Width="400px"
ErrorBackColor="Red" ThrobberID="Throbber"
onuploadedcomplete="AsyncFileUpload1_UploadedComplete"
UploadingBackColor="#66CCFF" />
如果它有任何区别,我使用它是因为 ToolkitScriptManager 似乎引入了其他错误,但这可能是我的错误:
<ajax:AjaxScriptManager ID="scriptmanager1" runat="server" EnablePartialRendering="true" ></ajax:AjaxScriptManager>
我不确定是否LoadScriptsBeforeUI
会很有用,但我相信我希望在实际加载脚本之前完成 UI。
我发现有趣的是,当 dom 树完成时,我设置的宽度实际上并未设置。
I am using the Nov version of the AjaxControlToolkit, and I found a logic error, but I am trying to figure out the best way to fix this, by Saturday, so that the program will work on IE.
This problem only has an error on IE, it works on Firefox3.5.
I have a AsyncFileUpload component on a tab that appears to not be visible when this function runs, and so the offset width is zero.
The problem is in the file AsyncFileUpload.pre.js
, in function _app_onload
, and this line:this._innerTB.style.width = (this._inputFile.offsetWidth - 107) + "px";
I don't want to compile it from the source, but this may end up being my best option, so I can fix the error.
But, this is probably going to be my fix:this._innerTB.style.width = ((this._inputFile.offsetWidth == 0) ? 200 : this._inputFile.offsetWidth) - 107) + "px";
But, I don't know if there is a better solution.
I could just write a new prototype function in my javascript class and just fix the logic error, which is better than recompiling. If I fix it in the code, then whenever I do an update I will need to keep replacing that line, until it gets fixed in the codebase.
But, I am trying to figure out if there is a way for an element to know that it has just become visible, as anytime you need to know the actual width of an element then you can't really set it up until it is displayed. I can't think of a way to know that, so what I tend to do is fix the elements on the tab the first time the tab is selected, but, for a generic library that is not a possible solution.
Location of the main question
So, before I send in a bug report about this I am curious if there is a better way to do it, rather than having it done when the page has been loaded, and assuming a minimum width that is probably wrong. <-- Question located here
I am using the follow code to create the element:
<cc1:AsyncFileUpload ID="AsyncFileUpload1" runat="server"
OnClientUploadError="uploadError" OnClientUploadStarted="StartUpload"
OnClientUploadComplete="UploadComplete"
CompleteBackColor="Lime" UploaderStyle="Modern" Width="400px"
ErrorBackColor="Red" ThrobberID="Throbber"
onuploadedcomplete="AsyncFileUpload1_UploadedComplete"
UploadingBackColor="#66CCFF" />
And if it makes any difference I am using this as the ToolkitScriptManager seemed to introduce other errors, but that may have been my error:
<ajax:AjaxScriptManager ID="scriptmanager1" runat="server" EnablePartialRendering="true" ></ajax:AjaxScriptManager>
I am not certain if LoadScriptsBeforeUI
would be useful, but I believe that I want the UI done before the scripts are loaded actually.
I find it interesting that the width I set isn't actually set when the dom tree is completed.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
尝试将此属性添加到您的脚本管理器
LoadScriptsBeforeUI="true"
我已经下载了源代码并修复了代码行,但它仍然无法正常工作,
然后我将此属性添加到脚本管理器中,它有效!
如果您想更改源代码,请查看此页面以了解详细信息
http://ajaxcontroltoolkit.codeplex.com/SourceControl/网络/Forks/keyoke/AyncFileUploadFix/changeset/changes/30da4b8d1c6d
try add this attribute to your scriptmanager
LoadScriptsBeforeUI="true"
I have download the source code and fix the codeline,but it still not working,
then I add this attr to the scriptmanager,it works !!
check this page for detail if U wanna change the source code
http://ajaxcontroltoolkit.codeplex.com/SourceControl/network/Forks/keyoke/AyncFileUploadFix/changeset/changes/30da4b8d1c6d
这是对我有用的解决方案:
Apply CssClass on
ajaxToolkit:AsyncFileUpload
like "imageUploaderField"编写Css
.imageUploaderField input{width:100%!important;}
源码:http://ajaxcontroltoolkit.codeplex.com/workitem/27429
This is the solution that's worked for me:
Apply CssClass on
ajaxToolkit:AsyncFileUpload
like "imageUploaderField"Write Css
.imageUploaderField input{width:100%!important;}
Source: http://ajaxcontroltoolkit.codeplex.com/workitem/27429
这不是理想的解决方案,但它确实有效,希望有人能有更好的解决方案,因为这是我无法提交来修复错误的东西。我将其添加到我的 javascript 文件中,但它是一个 hack,不是一个好的解决方案。由于我注释掉了这一行,我不得不替换第二个函数。
This isn't the ideal solution, but it does work, hopefully someone will have a better solution, as this is something I cannot submit to fix the bug. I added this to a javascript file of mine, but it is a hack, not a good solution. I had to replace the second function because of the line I commented out.
我的解决方案...可能不是最好的,但有效。
已在 http://ajaxcontroltoolkit.codeplex.com/SourceControl/network/Forks 分叉/keyoke/AyncFileUploadFix
My Solution... probably not the best but works.
have forked at http://ajaxcontroltoolkit.codeplex.com/SourceControl/network/Forks/keyoke/AyncFileUploadFix