Asp.net中UpdatePanel内包含FileUpload的使用

在Asp.net中UpdatePanel内包含FileUpload文件上传控件时候,在提交时,FileUpload控件中选择的文件不会被提交,需要在UpdatePanel进行设置,具体代码如下: [ 需添加 <Triggers> 属性]

<asp:UpdatePanel ID="UpdatePanel4" runat="server">
                    <ContentTemplate>
                        <table width="80%">
                    <tr>
                        <td class="title" colspan="2">添加新产品</td>
                    </tr>
                    <tr>
                        <td align="right" style="width:120px;">产品编码:</td>
                        <td align="left">
                            <asp:TextBox ID="txtProductCoder" runat="server" AutoPostBack="True" 
                                Width="350px" ontextchanged="txtProductCoder_TextChanged"></asp:TextBox>
                            &nbsp;<asp:CustomValidator ID="cvProductCoder" runat="server" 
                                ControlToValidate="txtProductCoder" Display="Dynamic" ErrorMessage="请输入产品编码!"></asp:CustomValidator>
                            <asp:CustomValidator ID="cvCoderIsExists" runat="server" 
                                ControlToValidate="txtProductCoder" Display="Dynamic" 
                                ErrorMessage="该产品编码已经存在,请重新输入!"></asp:CustomValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">产品名称:</td>
                        <td align="left">
                            <asp:TextBox ID="txtProductName" runat="server" Width="350px"></asp:TextBox>
                            &nbsp;<asp:CustomValidator ID="cvProductName" runat="server" 
                                ControlToValidate="txtProductName" Display="Dynamic" ErrorMessage="请输入产品名称!"></asp:CustomValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">产品类型:</td>
                        <td align="left">
                            <asp:DropDownList ID="ddlProductType" runat="server" 
                                DataSourceID="ODSAddProductType" DataTextField="productType_name" 
                                DataValueField="productType_id" Width="350px">
                            </asp:DropDownList>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">产品型号:</td>
                        <td align="left">
                            <asp:TextBox ID="txtProductModel" runat="server" Width="350px"></asp:TextBox>
                            <asp:CustomValidator ID="cvProductModel" runat="server" 
                                ControlToValidate="txtProductModel" Display="Dynamic" ErrorMessage="请输入产品型号!"></asp:CustomValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">产品规格:</td>
                        <td align="left">
                            <asp:TextBox ID="txtProductStandard" runat="server" Width="350px"></asp:TextBox>
                            &nbsp;<asp:CustomValidator ID="cvProductStandard" runat="server" 
                                ControlToValidate="txtProductStandard" Display="Dynamic" 
                                ErrorMessage="请输入产品规格!"></asp:CustomValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right">产品图片:</td>
                        <td align="left">
                            <asp:FileUpload ID="fuProductImage" runat="server" Width="350px" />
                            &nbsp;<asp:CustomValidator ID="cvUpdateImage" runat="server" 
                                ControlToValidate="fuProductImage" Display="Dynamic" ErrorMessage="上传失败!"></asp:CustomValidator>
                        </td>
                    </tr>
                    <tr>
                        <td align="right" valign="top">产品备注:</td>
                        <td align="left">
                            <asp:TextBox ID="txtProductRema" runat="server" Height="60px" 
                                TextMode="MultiLine" Width="550px"></asp:TextBox>
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2" align="center">
                            <asp:Button ID="btnAddProduct" runat="server" Text="添加" 
                                οnclick="btnAddProduct_Click" />
&nbsp;<input id="Reset2" type="reset" value="重置" />
                            <input id="Button2" type="button" value="关闭" /><br />
                            <asp:Label ID="lblAddProductInfo" runat="server" ForeColor="#006600"></asp:Label>
                        </td>
                    </tr>
                </table>
                </ContentTemplate>
                <Triggers>
                    <asp:PostBackTrigger ControlID ="btnAddProduct" /> <!-- btnAddProduct为提交按钮 -->
                </Triggers>
                </asp:UpdatePanel>
                </div>

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值