在更新面板中使用时,Html输入文件控件不会上载文件

时间:2013-04-13 09:31:23

标签: c# updatepanel htmlcontrols

伙计我有一个表格,我使用2 UpdatePanel s。当我尝试使用html输入文件控件上传文件时,我遇到了问题,它是上传空值。我的html输入类型文件控件位于第一个更新面板中。请提前帮助....

<%@ Page Title="InstructorView" Language="C#" MasterPageFile="~/AdminDashboard.Master"
    AutoEventWireup="true" CodeFile="InstructorView.aspx.cs" Inherits="Admin_InstructorView" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
    <link rel="shortcut icon" href="../App_Themes/Admintheme/images/LIT_Icon.ico" />
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <script language="javascript" type="text/javascript">

        function ConfirmDelete() {

            return confirm("Are u sure u want to delete this records?")
        }  
    </script>
    <ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
    </ajax:ToolkitScriptManager>
     <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional"  ChildrenAsTriggers="true"  runat="server">
                <ContentTemplate > 
    <div class="grid_16" id="content">
        <div class="grid_9">
            <h1 class="instructorprofile">
                Instructors Status</h1>
            <div class="portlet-content">
                <asp:GridView ID="grdInst" runat="server" AutoGenerateColumns="false" CellPadding="4"
                    Width="900px" OnRowDeleting="grdInst_RowViewing" AllowPaging="true" PageSize="10"
                    CssClass="box-table-a">
                    <%-- OnPageIndexChanging="grdInst_PageIndexChanging"--%>
                    <FooterStyle />
                    <Columns>
                        <asp:BoundField DataField="InstructorID" HeaderText="Instructor Code" ReadOnly="true"
                            ItemStyle-HorizontalAlign="Center" ItemStyle-Width="90px" />
                        <asp:BoundField DataField="FirstName" HeaderText="First Name" />
                        <asp:BoundField DataField="LastName" HeaderText="Last Name" />
                        <asp:BoundField DataField="IsActive" HeaderText="Status" />
                        <asp:TemplateField ItemStyle-Width="30px" HeaderText="View" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton ID="lkView" runat="server" CommandName="Delete" Text="" CssClass="view_icon"
                                    ToolTip="Click for View" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="30px" HeaderText="Edit" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton ID="lnkEdit" runat="server" Text="" CssClass="edit_icon" ToolTip="Click for Edit"
                                    OnClick="Edit"></asp:LinkButton>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField ItemStyle-Width="30px" HeaderText="" ItemStyle-HorizontalAlign="Center">
                            <ItemTemplate>
                                <asp:LinkButton ID="lkDelete" runat="server" CssClass="delete_icon" ToolTip="Click for Delete"
                                    OnClientClick='return confirm ("Are you sure you want to delete this entry?");'
                                    CommandName="Delete" OnClick="Delete" Text="" Visible="false" />
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <RowStyle />
                    <EditRowStyle />
                    <SelectedRowStyle />
                    <PagerStyle HorizontalAlign="Center" />
                    <HeaderStyle />
                    <AlternatingRowStyle />
                </asp:GridView>

                          </div>

            <asp:Panel ID="pnlInst" runat="server" Visible="false" Height="512px">


                <div class="grid_16" id="content_popup" style="margin: 0px auto; display: block;
                    float: none;">
                    <span style="display: block; float: right; margin-right: 0; margin-top: -10px;">
                        <asp:ImageButton ID="ImageButton2" ImageUrl="../AppImages/close-popup.png" runat="server" />
                    </span>
                    <h1 class="instructorprofile">
                        Instructor Details</h1>
                    <div class="portlet-content" 
                        style="overflow: auto; height: 400px; width: 370px;">
                        <label>
                            <asp:Label ID="Label20" runat="server" Text="Course I will be Teaching"></asp:Label></label>
                        <asp:DropDownList ID="drpCourseName" runat="server" CssClass="smallInput" AutoPostBack="true">
                        </asp:DropDownList>
                        <asp:TextBox ID="txtSpecialization" runat="server" Visible="false" CssClass="smallInput"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator9" runat="server" ControlToValidate="drpCourseName"
                            ErrorMessage="" ValidationGroup="1" Display="Dynamic">
                            <div class="error"> <p  class="info">
                    <span class="info_inner">Course Name is Required!</span></p></div>
                        </asp:RequiredFieldValidator>
                        <label>
                            <asp:Label ID="Label1" runat="server" Text="First Name"></asp:Label>
                        </label>
                        <asp:TextBox ID="txtFirstName" runat="server" CssClass="smallInput"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator7" runat="server" ControlToValidate="txtFirstName"
                            ErrorMessage="" ValidationGroup="1" Display="Dynamic">
                             <div class="error"> <p  class="info">
                    <span class="info_inner">First Name is Required!</span></p></div>
                        </asp:RequiredFieldValidator>
                        <label>
                            <asp:Label ID="Label2" runat="server" Text="Last Name"></asp:Label>
                        </label>
                        <asp:TextBox ID="txtLastName" CssClass="smallInput" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator8" runat="server" ControlToValidate="txtLastName"
                            ErrorMessage="" ValidationGroup="1" Display="Dynamic">
                             <div class="error"> <p  class="info">
                    <span class="info_inner">Last Name is Required!</span></p></div>
                        </asp:RequiredFieldValidator>
                        <label>
                            <asp:Label ID="Label10" runat="server" Text="Cell Number"></asp:Label></label>
                        <asp:TextBox ID="txtCellNumber1" CssClass="smallInput" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator13" runat="server" ControlToValidate="txtCellNumber1"
                            ErrorMessage="" ValidationGroup="1" Display="Dynamic"> 
                     <div class="error"> <p  class="info">
                                    <span class="info_inner">Cell Number is Required! </span></p></div>
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ControlToValidate="txtCellNumber1"
                            ErrorMessage="" ValidationExpression="^[0-9]*$" Display="Dynamic" ValidationGroup="1"> 
                     <div class="error"> <p  class="info">
                                    <span class="info_inner"> Invalid Format</span></p></div>
                        </asp:RegularExpressionValidator>
                        <label>
 <asp:Label ID="Label21" runat="server" Text="Email"></asp:Label></label>
                        <asp:TextBox ID="txtEmail" CssClass="smallInput" runat="server"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator14" runat="server" ControlToValidate="txtEmail"
                            ErrorMessage="" ValidationGroup="1" Display="Dynamic"> 
                     <div class="error"> <p  class="info">
                                    <span class="info_inner">Email is Required! </span></p></div>
                        </asp:RequiredFieldValidator>
                        <asp:RegularExpressionValidator ID="ValidateEmailAddress" ErrorMessage="Enter Valid Email ID"
                            ControlToValidate="txtEmail" runat="server" Display="Dynamic" ValidationExpression="\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*">

                     <div class="error"> <p  class="info">
                                    <span class="info_inner">Enter Valid Email Id! </span></p></div>
                        </asp:RegularExpressionValidator>
                        <label>
                            Upload Contract</label>
                        <input id="inputContract" type="file" runat="server" />
                        <asp:UpdatePanel ID="UpdatePanel2" UpdateMode="Conditional" ChildrenAsTriggers ="true"   runat="server"  >
                            <ContentTemplate>
                                <asp:Button ID="btnUpload" runat="server" CssClass="black_button" Text="Upload File"
                                    OnClick="btnUpload_Click" CausesValidation="false" />
                                 <asp:Label ID="lblContract" runat="server" Text="" Visible="true"></asp:Label>

                            </ContentTemplate>
                            <Triggers>
                                <asp:AsyncPostBackTrigger ControlID="btnUpload" EventName="Click" />
                            </Triggers>
                        </asp:UpdatePanel>

                      <asp:UpdateProgress ID="UpdateProgress1" AssociatedUpdatePanelID ="UpdatePanel1" runat="server">
                                    <ProgressTemplate>
                                        Please Wait while We Save Your Changes....<img alt="" src="../AppImages/ajax-loader-7.gif" />
                                    </ProgressTemplate>
                                </asp:UpdateProgress>  <label>
                            <asp:Label ID="Label7" runat="server" Text="Current Status"></asp:Label>
                        </label>
                        <asp:RadioButtonList ID="rbtnIsActive" runat="server" RepeatDirection="horizontal">
                            <asp:ListItem Value="True">Active&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</asp:ListItem>
                            <asp:ListItem Selected="True" Value="False">Blocked&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</asp:ListItem>
                        </asp:RadioButtonList>
                        <asp:Button ID="btnSave" runat="server" Text="Save" CssClass="black_button" 
                            ValidationGroup="1" onclick="btnSave_Click"
                            />

                        <asp:Button ID="btnCancel" runat="server" CssClass="black_button" Text="Cancel" OnClientClick="return Hidepopup()" />
                        <asp:Label ID="lblUserName" runat="server" Visible="false"></asp:Label>
                        <asp:Label ID="lblPassWord" runat="server" Visible="false"></asp:Label>
                    </div>
                </div>


            </asp:Panel>
            <asp:LinkButton ID="lnkFake" runat="server"></asp:LinkButton>
            <ajaxToolkit:ModalPopupExtender ID="popup" runat="server" DropShadow="false" PopupControlID="pnlInst"
                TargetControlID="lnkFake" >
            </ajaxToolkit:ModalPopupExtender>

        </div>
    </div>
     </ContentTemplate> 
                    <Triggers>
                        <asp:AsyncPostBackTrigger ControlID="btnSave" EventName="Click" />
                          </Triggers>
                </asp:UpdatePanel>  
</asp:Content>

1 个答案:

答案 0 :(得分:0)

更新面板上的必需触发器。