我有一个TabContainer
其中每个选项卡都有一个ModalPopupExtender
. 在每个里面ModalPopupExtender
我定义了一个AsyncFileUpload
.
我的目标是,当文件上传/失败时,它会在ModalPopupExtender
显示这一事实的内部显示一个标签。另外,我想TabPanel
用上传文件的信息更新对应的信息(在关闭之前或之后ModalPopupExtender
,对我来说都是一样的)。
我认为问题出ModalPopupExtender
在ContentTemplate
's内部TabPanel
,但我不知道解决方案。
我的标记代码:
<AjaxControlToolkit:TabPanel ID="tBrochure" runat="server" HeaderText="Brochure" OnDemandMode="Always" EnableViewState="true">
<ContentTemplate>
<asp:Label ID="lBrochureDesc" runat="server" Text="In this tab you can set or update the brochure document and its description for the Maintenance Contracts product." /><br /><br />
<asp:Label ID="lBrochureCurrentFile" runat="server" Text="Current File" CssClass="LabelForTextBox" />:
<asp:Label ID="lBrochureCurrentFileName" runat="server" Text="" /><br />
<asp:Label ID="lBrochureCurrentDateTag" runat="server" Text="Upload Date" CssClass="LabelForTextBox" />:
<asp:Label ID="lBrochureCurrentDate" runat="server" Text="" /><br /><br />
<asp:Panel ID="pBrochureUploadFileLink" runat="server" style="margin-left: 20px;">
<asp:ImageButton ID="ibBrochureUploadFile" runat="server" ImageUrl="~/Images/icon_add.png" Width="20px" style="vertical-align: middle" />
<asp:Label ID="lBrochureUploadFile" runat="server" Text="Upload a new document" style="vertical-align: middle" /><br />
</asp:Panel>
<asp:Panel ID="pBrochureUploadFilePopup" runat="server" CssClass="Popup" style="display:none;">
<asp:Panel ID="pBrochureUploadFilePopupTitleBar" runat="server" CssClass="PopupTitleBar">
<asp:ImageButton ID="imBrochureUploadFilePopupClose" runat="server" ImageUrl="~/Images/icon_close.png" />
</asp:Panel>
<asp:Panel ID="pBrochureUploadFilePopupContent" runat="server" CssClass="PopupContent">
<asp:Label ID="lBrochureUploadFilePopupTitle" runat="server" CssClass="title" Text="Upload a new file" />
<AjaxControlToolkit:AsyncFileUpload ID="fuBrochure" runat="server" CompleteBackColor="Green" ErrorBackColor="Red" /><br /><br />
<asp:Label ID="lBrochureUploadFileStatus" runat="server" Text="" />
<asp:Label ID="lBrochureUploadFileAdvice" runat="server" Text="The current file will be replaced but a backup of that version will be stored." />
</asp:Panel>
</asp:Panel>
<asp:Button ID="bBrochureDummy" runat="server" style="display:none;" />
<AjaxControlToolkit:ModalPopupExtender ID="mpeBrochureUpload" runat="server" ClientIDMode="Static"
TargetControlID="pBrochureUploadFileLink"
PopupControlID="pBrochureUploadFilePopup"
CancelControlID="imBrochureUploadFilePopupClose"
PopupDragHandleControlID="pBrochureUploadFilePopupTitleBar"
BackgroundCssClass="PopupBackground" DropShadow="true" />
<br /><br />
<asp:Label ID="lBrochureDescription" runat="server" Text="Description" CssClass="LabelForTextBox" />:<br />
<asp:TextBox ID="tbBrochureDescription" runat="server" TextMode="MultiLine" CssClass="TextBox" Style="height:50px; width:200px; max-width: 900px;"/><br /><br />
<asp:LinkButton ID="lbBrochureSave" runat="server" Text="Save" CssClass="ButtonWithArrow" />
<asp:LinkButton ID="lbBrochureCancel" runat="server" Text="Cancel" CssClass="ButtonWithArrow" />
</ContentTemplate>
</AjaxControlToolkit:TabPanel>
我的代码隐藏:
Protected Sub fuBrochure_UploadedComplete(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles fuBrochure.UploadedComplete
If fuBrochure.HasFile Then
Dim fileName As String = fuBrochure.FileName
Dim fileType As String = fuBrochure.ContentType
If Products.updateDoc(productId, Products.DocumentId.Brochure, fileName, fileType) Then
fuBrochure.SaveAs(MapPath(path + fileName))
End If
UpdateBrochurePanel()
lBrochureUploadFileStatus.Text = "File uploaded succesfully!"
mpeBrochureUpload.Hide()
End If
End Sub
Protected Sub fuBrochure_UploadedFileError(ByVal sender As Object, ByVal e As AjaxControlToolkit.AsyncFileUploadEventArgs) Handles fuBrochure.UploadedFileError
lBrochureUploadFileStatus.Text = "Error!"
End Sub
在这段代码中,这些行:
lBrochureUploadFileStatus.Text = "File uploaded succesfully!"
mpeBrochureUpload.Hide()
什么都不做,但线
fuBrochure.SaveAs(MapPath(path + fileName))
工作正常。
谢谢!