我正在开发一个内部Web应用程序,它可以收集各种图像并自动将它们绘制到更大的图像上。我在使用Microsoft的AJAX工具包中的ajaxFileUpload控件时遇到了问题。
在页面中,用户可以选择在文本框中填写ID号,然后单击按钮以获取一些文本数据(图像的元数据)并填充几个文本框/下拉列表。用户还可以选择单击按钮从本地系统上载图像以进行处理。 ajaxFileUpload控件位于UpdatePanel上。
当用户使用“填充”功能检索元数据然后选择上传图像时,“选择文件”按钮不会触发本地系统上的“打开文件”对话框。
当用户在检索元数据之前首次尝试上传图像时,“选择文件”按钮会弹出“打开文件”对话框,以允许用户选择所需的文件。
ajaxFileUpload控件在第一种情况下按预期工作;我假设如果我真的可以选择要上传的文件,那么剩下的过程就可以了。
发布尝试解决此问题需要哪些代码? ASPX?后端VB?
标记:
<asp:UpdatePanel runat = "server" ID = "upMain" >
<ContentTemplate>
<asp:Label runat = "server" ID = "lblImageBuilderTitle" Text = "Image Builder" CssClass = "panelTitle" />
<asp:Table runat = "server">
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "JTN: " />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat = "server" ID = "tbJTN" /><asp:Button runat = "server" ID = "btnPopulate" Text = "+" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Job Ref: " />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat = "server" ID = "tbJobRef" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Customer: " />
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat = "server" ID = "ddlImageBuilderCustomer" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Type: " />
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat = "server" ID = "ddlImageBuilderType" AutoPostBack = "true" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Email to Deana: " />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbEmailDeana" Checked = "true" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Email to Amy: " />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbEmailAmy" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Rego Branding: " Visible = "false" />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbRegoBranding" Visible = "false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan = "2" HorizontalAlign = "Center">
<asp:Label runat = "server" Text = "Images: " /><br />
<asp:GridView runat = "server" ID = "gvImages" AutoGenerateColumns = "false" AutoGenerateSelectButton = "false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat = "server" ID = "lblOriginalName" Text = "<%# Bind('original_filename') %>" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat = "server" ID = "btnRowUp" CommandName = "Reorder" CommandArgument = "Up" />
<asp:Button runat = "server" ID = "btnRowDown" CommandName = "Reorder" CommandArgument = "Down" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>No images uploaded.</EmptyDataTemplate>
</asp:GridView>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:ModalPopupExtender runat = "server" ID = "mpePopulate" TargetControlID = "btnPopulateDummy" PopupControlID = "pnlPopulate" BackgroundCssClass = "modalBackground" />
<asp:Button runat = "server" ID = "btnPopulateDummy" CssClass = "invisible" />
<asp:ModalPopupExtender runat = "server" ID = "mpeUpload" TargetControlID = "btnUpload" PopupControlID = "pnlUpload" CancelControlID = "btnUploadClose" BackgroundCssClass = "modalBackground" />
<asp:Button runat = "server" ID = "btnUpload" Text = "Upload Images" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "gvPopulate" EventName = "SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID = "btnUploadClose" EventName = "Click" />
<asp:AsyncPostBackTrigger ControlID = "gvImages" EventName = "DataBound" />
<asp:AsyncPostBackTrigger ControlID = "ajuImageUpload" EventName = "UploadComplete" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdatePanel runat = "server" ID = "upMain" >
<ContentTemplate>
<asp:Label runat = "server" ID = "lblImageBuilderTitle" Text = "Image Builder" CssClass = "panelTitle" />
<asp:Table runat = "server">
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "JTN: " />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat = "server" ID = "tbJTN" /><asp:Button runat = "server" ID = "btnPopulate" Text = "+" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Job Ref: " />
</asp:TableCell>
<asp:TableCell>
<asp:TextBox runat = "server" ID = "tbJobRef" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Customer: " />
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat = "server" ID = "ddlImageBuilderCustomer" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Type: " />
</asp:TableCell>
<asp:TableCell>
<asp:DropDownList runat = "server" ID = "ddlImageBuilderType" AutoPostBack = "true" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Email to Deana: " />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbEmailDeana" Checked = "true" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Email to Amy: " />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbEmailAmy" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell HorizontalAlign = "Right" Width = "10%">
<asp:Label runat = "server" Text = "Rego Branding: " Visible = "false" />
</asp:TableCell>
<asp:TableCell>
<asp:CheckBox runat = "server" ID = "cbRegoBranding" Visible = "false" />
</asp:TableCell>
</asp:TableRow>
<asp:TableRow>
<asp:TableCell ColumnSpan = "2" HorizontalAlign = "Center">
<asp:Label runat = "server" Text = "Images: " /><br />
<asp:GridView runat = "server" ID = "gvImages" AutoGenerateColumns = "false" AutoGenerateSelectButton = "false">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label runat = "server" ID = "lblOriginalName" Text = "<%# Bind('original_filename') %>" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button runat = "server" ID = "btnRowUp" CommandName = "Reorder" CommandArgument = "Up" />
<asp:Button runat = "server" ID = "btnRowDown" CommandName = "Reorder" CommandArgument = "Down" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<EmptyDataTemplate>No images uploaded.</EmptyDataTemplate>
</asp:GridView>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<asp:ModalPopupExtender runat = "server" ID = "mpePopulate" TargetControlID = "btnPopulateDummy" PopupControlID = "pnlPopulate" BackgroundCssClass = "modalBackground" />
<asp:Button runat = "server" ID = "btnPopulateDummy" CssClass = "invisible" />
<asp:ModalPopupExtender runat = "server" ID = "mpeUpload" TargetControlID = "btnUpload" PopupControlID = "pnlUpload" CancelControlID = "btnUploadClose" BackgroundCssClass = "modalBackground" />
<asp:Button runat = "server" ID = "btnUpload" Text = "Upload Images" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "gvPopulate" EventName = "SelectedIndexChanged" />
<asp:AsyncPostBackTrigger ControlID = "btnUploadClose" EventName = "Click" />
<asp:AsyncPostBackTrigger ControlID = "gvImages" EventName = "DataBound" />
<asp:AsyncPostBackTrigger ControlID = "ajuImageUpload" EventName = "UploadComplete" />
</Triggers>
</asp:UpdatePanel>
代码隐藏:
Private Sub ImageBuilder_PreRender(sender As Object, e As System.EventArgs) Handles Me.PreRender
Dim dtIBImages As New DataTable
If IsPostBack = False Then
BindCustomerDDL("ImageBuilder")
BindCategoryDDL("ImageBuilder")
BindTemplatesDDL()
'Session("dtIBImages") = Nothing
'dtIBImages.Columns.Add("id")
'dtIBImages.Columns.Add("original_filename")
'dtIBImages.Columns.Add("image_filename")
'dtIBImages.Columns.Add("disposition")
' Session("dtIBImages") = dtIBImages
Else
dtIBImages = Session("dtIBImages")
gvImages.DataSource = dtIBImages
gvImages.DataBind()
End If
dtIBImages = Session("dtIBImages")
gvImages.DataSource = dtIBImages
gvImages.DataBind()
End Sub