我在我的项目中使用 Devexpress UploadControl for MVC。我正在使用弹出窗口来上传放置文件上传控件的文件。如果我多次单击按钮触发该弹出窗口,则上传控制文本显示为“未定义”。此问题仅在 Google Chrome 中发生
见截图
UploadControl 的代码使用如下:
<dl class="uploadProviderDoc">
@Html.DevExpress().UploadControl(settings =>
{
settings.Name = "Document";
settings.ClientSideEvents.TextChanged = "function(s,e){$('label[for=lblUploadMsg]').html(' ');}";
}).GetHtml()
@Html.Label("lblUploadMsg", " ")
</dl>
我检查了 Google Chrome 的控制台,发现了引发该错误的代码行。
RedefineInputAttributes: function(textBoxCell, index, isNewElement) {
textBoxCell.id = this.GetTextBoxCellID(index);
if(this.IsSlUploadHelperEnabled()) {
if(this.GetSlUploadHostElement())
this.slUploadHelper.RedefineSlObjectAttributesInHostElement(index + 1, index, isNewElement);
else
this.slUploadHelper.RedefineSlObjectAttributes(textBoxCell, index, isNewElement);
}
else {
var inputElement = _aspxGetChildByTagName(textBoxCell, "INPUT", 0);
inputElement.id = textBoxCell.id + ASPxClientUploadControlIDSuffix.FileInput;
//Uncaught TypeError: Cannot set property 'id' of null (This exception is thrown here)
inputElement.name = inputElement.id;
}
var fakeInputElement = _aspxGetChildByTagName(textBoxCell, "INPUT", this.IsSlUploadHelperEnabled() ? 0 : 1);
if(fakeInputElement)
fakeInputElement.id = textBoxCell.id + ASPxClientUploadControlIDSuffix.FileFakeInput;
}